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

import error #889

Closed
Aspirinkb opened this issue Oct 18, 2017 · 10 comments
Closed

import error #889

Aspirinkb opened this issue Oct 18, 2017 · 10 comments

Comments

@Aspirinkb
Copy link

  1. python 3.6
  2. dlib 19.7
  3. Mac OS

When import dlib:

import dlib
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dlib-19.7.99-py3.6-macosx-10.6-intel.egg/dlib/__init__.py", line 1, in <module>
    from .dlib import *
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/dlib-19.7.99-py3.6-macosx-10.6-intel.egg/dlib/dlib.so, 2): Symbol not found: _PyClass_Type
  Referenced from: /usr/local/opt/boost-python/lib/libboost_python-mt.dylib
  Expected in: flat namespace
 in /usr/local/opt/boost-python/lib/libboost_python-mt.dylib

Any help?

@davisking
Copy link
Owner

@Aspirinkb
Copy link
Author

Aspirinkb commented Oct 19, 2017

Yes, I have more than one copy of Python installed on my Mac and they are

  1. /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
  2. /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
  3. /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  4. /usr/bin/python
  5. ~/anaconda/envs/py35/bin/python
  6. ~/anaconda/envs/py27/bin/python

I pip3 install dlib for python3.6. So, how should I complie Boost and dlib against python 3.6?

@davisking
Copy link
Owner

davisking commented Oct 19, 2017 via email

@Aspirinkb
Copy link
Author

I brew install boost-python --with-python3 and run python3 setup.py install --yes USE_AVX_INSTRUCTIONS. But same error when import dlib. I think I should try some other way of installing boost-python.

@Aspirinkb
Copy link
Author

stackoverflow solution to correct boost-python error.

@Aspirinkb
Copy link
Author

Aspirinkb commented Oct 19, 2017

  1. uninstall boost-python for python2
    brew uninstall boost-python
  2. install boost-python for python3
    brew install boost-python --with-python3
  3. change name of libboost_python3 to libboost_python
    cd /usr/local/opt/boost-python/lib/
    ls, and got something like this:
libboost_python-mt.a            libboost_python3-mt.a
libboost_python-mt.dylib        libboost_python3-mt.dylib
libboost_python.a               libboost_python3.a
libboost_python.dylib           libboost_python3.dylib

backup boost-python for python2 and change boost-python for python3:

mv libboost_python-mt.a libboost_python2-mt.a && cp libboost_python3-mt.a libboost_python-mt.a
mv libboost_python-mt.dylib libboost_python2-mt.dylib && cp libboost_python3-mt.dylib libboost_python-mt.dylib
mv libboost_python.a libboost_python2.a && cp libboost_python3.a libboost_python.a
mv libboost_python.dylib libboost_python2.dylib && cp libboost_python3-mt.dylib libboost_python.dylib
  1. clone dlib from github and cd dlib
    python3 setup.py install --yes USE_AVX_INSTRUCTIONS

Done!

@davisking
Copy link
Owner

Sweet, thanks for reporting how to fix it :)

@MaffooBristol
Copy link

Thank you for the instructions! Slight typo though (needs double ampersand not single, otherwise it gets confused and tries to create daemons!)

mv libboost_python-mt.a libboost_python2-mt.a && cp libboost_python3-mt.a libboost_python-mt.a
mv libboost_python-mt.dylib libboost_python2-mt.dylib && cp libboost_python3-mt.dylib libboost_python-mt.dylib
mv libboost_python.a libboost_python2.a && cp libboost_python3.a libboost_python.a
mv libboost_python.dylib libboost_python2.dylib && cp libboost_python3-mt.dylib libboost_python.dylib

@drhoffma
Copy link

drhoffma commented Dec 17, 2017

I found that using an older version of boost on macOS fixed things for me:

brew install homebrew/versions/boost155

@lucasjinreal
Copy link

The @Aspirinkb 's solution are not work at all. Still same error after do this.

@ghost ghost mentioned this issue Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants