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

ImportError: No module named cv_bridge_boost on Mac OS X #17

Closed
venabled opened this issue Aug 12, 2013 · 17 comments
Closed

ImportError: No module named cv_bridge_boost on Mac OS X #17

venabled opened this issue Aug 12, 2013 · 17 comments

Comments

@venabled
Copy link

This seems to be related to ros-perception/image_pipeline#34

We (myself and @kyonifer) built groovy-dekstop using MacPorts on OS X 10.7.5 , and on using opencv_bridge (version 1.10.7) in python get the message:

ImportError: No module named cv_bridge_boost

More guessing that it has to do with something not detecting that cv_bridge_boost.dylib is created when compiling on the Mac vs cv_bridge_boost.so.

The library is compiled, and exists under $PYTHON_PATH at /opt/local/lib/python2.7/site-packages/cv_bridge/boost

edward:cv_bridge venabled$ ls -l /opt/local/lib/python2.7/site-packages/cv_bridge/boost
total 320
-rw-r--r--  1 root  admin       0 Aug  7 17:54 __init__.py
-rwxr-xr-x  1 root  admin  160988 Aug  7 17:55 cv_bridge_boost.dylib

Full code traceback:

Traceback (most recent call last):
  File "./evaluate_pnp.py", line 221, in <module>
    aspn_meas = np.array(bridge.imgmsg_to_cv(msg))
  File "/opt/local/lib/python2.7/site-packages/cv_bridge/core.py", line 101, in imgmsg_to_cv
    source_type = self.encoding_as_cvtype(img_msg.encoding)
  File "/opt/local/lib/python2.7/site-packages/cv_bridge/core.py", line 73, in encoding_as_cvtype
    from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: No module named cv_bridge_boost
@vrabaud
Copy link
Contributor

vrabaud commented Aug 12, 2013

Yes indeed. I have no experience with Mac. @wjwwood , any input on that ? Thx. It seems Python modules have to be named .so
http://mail.python.org/pipermail/pythonmac-sig/2007-February/018677.html
I could not find anything really firm about it though.

@wjwwood
Copy link
Member

wjwwood commented Aug 12, 2013

Sounds plausible, @venabled can you try just renaming the installed .dylib file to .so?

@wjwwood
Copy link
Member

wjwwood commented Aug 12, 2013

Or better yet use a symbolic link?

@vrabaud
Copy link
Contributor

vrabaud commented Aug 12, 2013

can you please check how other libraries do their Python compiled libraries ? e.g., is it cv2.so or dylib for OpenCV ?

@wjwwood
Copy link
Member

wjwwood commented Aug 12, 2013

It is .so:

/Users/william/hydro/install_isolated/lib/python2.7/site-packages/cv2.so

@venabled
Copy link
Author

It ends up with a SegFault if I do either symlink, or create a copy of the thing:

Segmentation fault: 11

Here's what the directory looks like:

edward:boost venabled$ ls -l
total 328
-rw-r--r--  1 root  admin       0 Aug  7 17:54 __init__.py
-rwxr-xr-x  1 root  admin  160988 Aug  7 17:55 cv_bridge_boost.dylib
lrwxr-xr-x  1 root  admin      23 Aug 12 15:41 cv_bridge_boost.so -> ./cv_bridge_boost.dylib

@vrabaud
Copy link
Contributor

vrabaud commented Aug 12, 2013

ok, we're getting somewhere :) So that is the main issue. @wjwwood , you are aware of that .so .dylib issue ? Should there be a catkin variable to set the shared library extension ?

For your segfault @venabled , any way you could gdb that ?

@wjwwood
Copy link
Member

wjwwood commented Aug 12, 2013

I vaguely remember it, I think that I have made a similar fix in either moveit or rqt.

@vrabaud
Copy link
Contributor

vrabaud commented Aug 12, 2013

can you guys please try the fix ? (that should fix the import). There is still the segfault apparently, please provide a backtrace for that.
Thx @wjwwood for your insight. I like my fix better though :)

@venabled
Copy link
Author

I am a gdb newb, but here's my backtrace:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000001123bf928 in PyEval_GetGlobals ()
#2  0x00000001123d7479 in PyImport_Import ()
#3  0x00000001123d7612 in PyImport_ImportModule ()
#4  0x000000010d6cdc70 in init_module_cv_bridge_boost ()
#5  0x0000000111e2e8e7 in boost::python::handle_exception_impl ()
#6  0x0000000111e2f95b in boost::python::handle_exception<void (*)()> ()
#7  0x0000000111e2f832 in boost::python::detail::init_module ()
#8  0x000000010d6cdc4b in initcv_bridge_boost ()
#9  0x00000001000bdb21 in _PyImport_LoadDynamicModule ()
#10 0x00000001000bd854 in import_submodule ()
#11 0x00000001000bd3dc in load_next ()
#12 0x00000001000bb32f in PyImport_ImportModuleLevel ()
#13 0x000000010009b758 in builtin___import__ ()
#14 0x00000001000118b1 in PyObject_Call ()
#15 0x00000001000a7338 in PyEval_CallObjectWithKeywords ()
#16 0x00000001000a48f2 in PyEval_EvalFrameEx ()
#17 0x00000001000a7b22 in fast_function ()
#18 0x00000001000a2d38 in PyEval_EvalFrameEx ()
#19 0x00000001000a0596 in PyEval_EvalCodeEx ()
#20 0x00000001000a7b8d in fast_function ()
#21 0x00000001000a2d38 in PyEval_EvalFrameEx ()
#22 0x00000001000a0596 in PyEval_EvalCodeEx ()
#23 0x000000010009fdc6 in PyEval_EvalCode ()
#24 0x00000001000c6e3e in PyRun_FileExFlags ()
#25 0x00000001000c69a0 in PyRun_SimpleFileExFlags ()
#26 0x00000001000da7a8 in Py_Main ()
#27 0x0000000100001f24 in dyld_stub_strlen ()
(gdb) quit

Was also getting a bunch of warnings from gdb in finding different object files related to boost.

@vrabaud
Copy link
Contributor

vrabaud commented Sep 9, 2013

wait, so you still got the bug after my fix ? Should I reopen ? @wjwwood does that work for you ? thx

@wjwwood
Copy link
Member

wjwwood commented Sep 9, 2013

I think this is a separate issue, I haven't reproduced it locally, but it looks like a segfault in the boost python wrapper. I would open a new issue for this (The original problem has been solved here).

@wjwwood
Copy link
Member

wjwwood commented Sep 9, 2013

After doing the symbolic link I can do the import:

william@dosa:~
% hydro

william@dosa:~
% python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cv_bridge.boost.cv_bridge_boost import getCvType
>>>

@vrabaud
Copy link
Contributor

vrabaud commented Sep 9, 2013

thx @wjwwood . @venabled , does it work for you too now ?

@venabled
Copy link
Author

venabled commented Sep 9, 2013

No sorry guys. Same segfault.

levin:bags venabled$ python
Python 2.7.5 (default, Aug  1 2013, 01:01:17)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cv_bridge.boost.cv_bridge_boost import getCvType
Segmentation fault: 11

I agree with @wjwwood that it's probably something with boost::python due to the backtrace above (maybe due to the specific version of boost::python we're using in macports)

I haven't put a lot of work into figuring it out and just bypassed cv_bridge for python and used PIL/numpy/opencv do do what I need to.

@wjwwood
Copy link
Member

wjwwood commented Sep 9, 2013

I am using Homebrew, which uses boost 1.53.0 or 1.54.0 and the system provided Python, but other than that I don't know how they are different.

luca-della-vedova pushed a commit to luca-della-vedova/vision_opencv that referenced this issue Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants