Search code examples
pythonpython-3.xboostdlibdlib-python

Python multi-version error _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE


I have an error when running app with python3.5

Traceback (most recent call last):                                                                                                                                              
  File "/usr/local/bin/face_recognition", line 7, in <module>                                                                                                                   
    from face_recognition.cli import main                                                                                                                                       
  File "/usr/local/lib/python3.5/site-packages/face_recognition/__init__.py", line 7, in <module>                                                                               
    from .api import load_image_file, face_locations, face_landmarks, face_encodings, compare_faces, face_distance                                                              
  File "/usr/local/lib/python3.5/site-packages/face_recognition/api.py", line 4, in <module>                                                                                    
    import dlib                                                                                                                                                                 
  File "/usr/local/lib/python3.5/site-packages/dlib/__init__.py", line 1, in <module>                                                                                           
    from .dlib import *                                                                                                                                                         
ImportError: /usr/local/lib/python3.5/site-packages/dlib/dlib.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE

I can see that libboost is the problem, I compiled it with appropriate version of python and set python root as well but still have an error. What did I miss?


Solution

  • I also meet this kind of problem. On my Mac, I have installed a version of boost 1.58 from source code.

    When I try to install dlib by following command:

    brew install cmake
    brew install boost
    brew install boost-python --with-python3
    sudo pip3 install numpy
    sudo pip3 install scipy
    sudo pip3 install scikit-image 
    sudo pip3 install dlib
    

    I think dlib use the wrong version of boost on my Mac.

    Here is my solution:

    1. try to delete boost using brew uninstall, and delete all related boost include and lib files from /usr/local/include & /usr/local/lib.

    2. reinstall above brew & pip3 commands to reinstall all related libraries.

    After this two steps, my Mac now can use dlib under Python3 correctly.