No module named 'parrot.protobuf' when running from ROS Foxy package
GCidd opened this issue · 5 comments
Hello,
I have created a ROS workspace and package which uses the olympe library, which was via pip on python 3.8.10. I tested the installation by running import olympe
from the python terminal and works fine.
When I build my ROS package and run it, it fails to find the ‘parrot.protobuf’ module.
The exception traceback can be seen below:
ModuleLoader unhandled exception
Traceback (most recent call last):
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/proto.py", line 628, in parse_proto
module = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/tmprfo7ojxe/arsdk/led_pb2.py", line 17, in <module>
ModuleNotFoundError: No module named 'parrot.protobuf'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/module_loader.py", line 70, in add_package_root
self.enums[root] = ArsdkEnums.get(root)
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/enums.py", line 438, in get
ret = ArsdkEnums(root)
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/enums.py", line 448, in __init__
self._proto = ArsdkProto.get(root)
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/proto.py", line 201, in get
ret = ArsdkProto(root)
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/proto.py", line 257, in __init__
self.parse_protos()
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/proto.py", line 542, in parse_protos
_, feature = self.parse_proto(
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/proto.py", line 633, in parse_proto
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/tmprfo7ojxe/arsdk/led_pb2.py", line 17, in <module>
ModuleNotFoundError: No module named 'parrot.protobuf'
Traceback (most recent call last):
File "/home/gcid/agro4/install/parrot/lib/parrot/parrot_drone", line 11, in <module>
load_entry_point('parrot==0.0.0', 'console_scripts', 'parrot_drone')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/gcid/agro4/install/parrot/lib/python3.8/site-packages/parrot/parrot_drone.py", line 20, in <module>
import olympe
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/__init__.py", line 32, in <module>
from .controller import Drone, SkyController
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/controller.py", line 32, in <module>
from .arsdkng.cmd_itf import Connect, Disconnect, Connected, Disconnected # noqa
File "/home/gcid/.local/lib/python3.8/site-packages/olympe/arsdkng/cmd_itf.py", line 41, in <module>
from olympe.enums import drone_manager as drone_manager_enums
ModuleNotFoundError: No module named 'olympe.enums'
The error will be thrown only AFTER I source the package’s source files by running
. install/setup.bash
Before running the above command the olympe module is imported just fine without any errors.
I have tried installing and importing olympe by following the steps suggested by ROS here, through a virtual environment inside the workspace, but it still doesn’t work.
Hello,
I am not familiar with ROS but, it seems that whatever this "install/setup.bash" script is doing to initialize the ROS workspace is what is causing your issue.
Since the parrot.protobuf package is provided by the parrot-olympe wheel package, I guess that this script is changing the PYTHONPATH environment variable.
Thank you for the quick reply.
It does change the PYTHONPATH, but it is not set before running the setup script.
I included the python's site-packages directory (.local/lib/python3.8/site-packages) in the variable's value, after running the setup script, but I still receive the error.
The script adds paths to other site-packages directories under the project's directory.
ROS might be using Python2 and Olympe runs on Python3. That might be another cause of the error. What are your ROS, Ubuntu and Olympe versions?
I am using ROS Foxy (which uses python 3.8), Ubuntu 20.04 and the latest olympe version installed with the pip package manager (on python 3.8)
If you still have this issue with ROS, you should ask your question on the Parrot Developer forum just in case someone in the community has experienced this issue.