python-rtmbot
python-rtmbot copied to clipboard
Problems with importing plugins
- [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Description
Something causes problems in importing plugins from the bot's directory. Since the pip install installs plugins/repeat.py in Python's library directory, it overrides the one in the bot's directory.
My custom plugins are in /opt/rtmbot/plugins. I set the BASE_PATH to /opt/rtmbot, but that didn't help.
I tried installing in a virtualenv and with the system Python. System Python seems to work better for some reason.
I added a debug print of sys.path before the module loading code.
This is from the system Python install:
['/usr/local/bin',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages',
'/opt/rtmbot']
And this is from the virtualenv:
['/opt/rtmbot/venv/bin',
'/opt/rtmbot/venv/lib/python36.zip',
'/opt/rtmbot/venv/lib/python3.6',
'/opt/rtmbot/venv/lib/python3.6/lib-dynload',
'/usr/lib/python3.6',
'/opt/rtmbot/venv/lib/python3.6/site-packages',
'/opt/rtmbot']
If I change /opt/rtmbot/plugins to /opt/rtmbot/more-plugins, for example, I can get the plugin to load.
Reproducible in:
- [ ] This is reproducible in the sample project. RTMBot version: 0.4.1 Python version: 3.6.6 OS Version: Ubuntu 18.04
Expected result:
No import errors.
Actual result:
Rtmbot fails to start due to not finding my plugins.
Attachments:
The actual error:
Traceback (most recent call last):
File "/opt/rtmbot/venv/bin/rtmbot", line 11, in <module>
sys.exit(main())
File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/bin/run_rtmbot.py", line 31, in main
bot.start()
File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/core.py", line 100, in start
self._start()
File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/core.py", line 75, in _start
self.load_plugins()
File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/core.py", line 160, in load_plugins
cls = import_string(plugin_path)
File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/opt/rtmbot/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plugins.cve'
The sys.paths look good to me, I'm not sure why it works differently.
/opt/rtmbot/venv/lib/python3.6/site-packages/plugins/ is the one causing the problems in the virtualenv case.
I had this problem too. I didn't have much time to investigate so, I just set the pip installation version back to 0.4.0 which worked for me.
I have the same issue with 0.4.1. 0.4.0 seems ok.
It seems that rtmbot doesnt detect changes made to the plugin files. I created a plugin for testing, then when I started modifying it, it stick with the first version it read. then when I changed the code and plugin name, it started complaining about importing module.
Hey all,
We're still looking into this but for the moment it appears the cfg file is referencing the wrong plugins folder as you mentioned. If you rename your customs plugin folder to something else and then use that in your config file, you should get past without the import errors that you've been seeing.
renaming the plugin folder worked for me. thanks!