Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Foxy] cv_bridge import broken with unreported exception #339

Closed
SteveMacenski opened this issue Jun 12, 2020 · 9 comments · Fixed by #342
Closed

[Foxy] cv_bridge import broken with unreported exception #339

SteveMacenski opened this issue Jun 12, 2020 · 9 comments · Fixed by #342
Assignees
Labels

Comments

@SteveMacenski
Copy link
Member

SteveMacenski commented Jun 12, 2020

Hi,

I noticed in image_pipeline's CI that there's an unreported exception due to cv_bridge. Job is here http://build.ros2.org/job/Fpr__image_pipeline__ubuntu_focal_amd64/2/console

12:17:57     from camera_calibration.calibrator import MonoCalibrator, StereoCalibrator, \
12:17:57 src/camera_calibration/calibrator.py:41: in <module>
12:17:57     import cv_bridge
12:17:57 /opt/ros/foxy/lib/python3.8/site-packages/cv_bridge/__init__.py:6: in <module>
12:17:57     from cv_bridge.boost.cv_bridge_boost import cvtColorForDisplay, getCvType
12:17:57 E   SystemError: initialization of cv_bridge_boost raised unreported exception
12:17:57 ---- generated xml file: /tmp/ws/test_results/camera_calibration/pytest.xml ----

I suspected CI issues, but in an ipython3 session locally I see the same thing with released debians

steve@Eve:~$ source /opt/ros/foxy/setup.bash 
^[[A^[[Asteveipython3
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cv_bridge                                                        
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: FATAL: module compiled as little endian, but detected different endianness at runtime
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-1-19d934114051> in <module>
----> 1 import cv_bridge

/opt/ros/foxy/lib/python3.8/site-packages/cv_bridge/__init__.py in <module>
      4 # This try is just to satisfy doc jobs that are built differently.
      5 try:
----> 6     from cv_bridge.boost.cv_bridge_boost import cvtColorForDisplay, getCvType
      7 except ImportError:
      8     pass

SystemError: initialization of cv_bridge_boost raised unreported exception

So this appears to be a genuine issue. The offending line: https://github.com/ros-perception/vision_opencv/blob/noetic/cv_bridge/python/cv_bridge/__init__.py#L6

@SteveMacenski SteveMacenski changed the title [Foxy] cv_bridge broken [Foxy] cv_bridge import broken with unreported exception Jun 12, 2020
@SteveMacenski
Copy link
Member Author

Upstream master doesn't seem to exhibit, so I think it was already fixed and foxy just needs to be updated potentially.

@mjcarroll
Copy link
Contributor

I managed to get a little further and surface this error in GDB:

RuntimeError: FATAL: module compiled as little endian, but detected different endianness at runtime

Which doesn't make a ton of sense, given that x86 compile-time and runtime should both be little endian.

@mjcarroll
Copy link
Contributor

It looks like it may be potentially addressed by #292

@jacobperron
Copy link
Contributor

See #346 for a fix.

@mjcarroll
Copy link
Contributor

Closed by #342

@togaen
Copy link

togaen commented Nov 25, 2020

In case it helps anyone else: I just ran into this error, but doing apt install python3-opencv seems to have resolved whatever the problem was.

@asimonov
Copy link

I am seeing this issue on Noetic on ARM64 (Jetson NX)

I run ubuntu20 in docker and see this (with default cv_bridge)

# source /opt/ros/noetic/setup.bash 
# roscd cv_bridge
/opt/ros/noetic/share/cv_bridge# python
Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv_bridge
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/ros/noetic/lib/python3/dist-packages/cv_bridge/__init__.py", line 6, in <module>
    from cv_bridge.boost.cv_bridge_boost import cvtColorForDisplay, getCvType
SystemError: initialization of cv_bridge_boost raised unreported exception
>>> 

and if I take current master and build it in my workspace I see the same issue:

root@uc1-nx-1:~/git/catkin_ws# source devel/setup.bash 
root@uc1-nx-1:~/git/catkin_ws# roscd cv_bridge
root@uc1-nx-1:~/git/catkin_ws/src/vision_opencv/cv_bridge# python
Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
>>> import cv_bridge
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tii/git/catkin_ws/devel/lib/python3/dist-packages/cv_bridge/__init__.py", line 34, in <module>
    exec(__fh.read())
  File "<string>", line 6, in <module>
SystemError: initialization of cv_bridge_boost raised unreported exception
>>> 

Any ideas how to debug/fix?

@asimonov
Copy link

also, there is this URL describing same error on ARM64: https://answers.ros.org/question/350904/cv_bridge-throws-boost-import-error-in-python-3-and-ros-melodic/, but is for Melodic. And it also lists no solution, but a workaround to not use cv_bridge functions.

@asimonov
Copy link

asimonov commented May 4, 2021

after rebuilding ROS Noetic from source on Jetson NX and still seeing the same issue I have found a workaround:

opencv/opencv#14884 (comment)

import cv2 has to happen first in python scripts. then 'import cv_bridge' works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants