Search code examples
pythonsdkpepper

Problem trying to install Naoqi Python-SDK: "SystemError: dynamic module not initialized properly"


I saw someone was answering the same question here: Python for Naoqi (dynamic module not initialized properly), but I follow the answers in the page, still cannot get it working. Could someone advice how to proceed?

Using Python 2.7.10 doesn't help. Under Anaconda Python 2.7.10:

Python 2.7.10 |Continuum Analytics, Inc.| (default, Oct 19 2015, 18:31:17) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import naoqi
Traceback (most recent call last):
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 557, in <module>
    main()
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 539, in main
    known_paths = addusersitepackages(known_paths)
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 275, in addusersitepackages
    user_site = getusersitepackages()
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 250, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 240, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/sysconfig.py", line 520, in get_config_var
    return get_config_vars().get(name)
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/sysconfig.py", line 453, in get_config_vars
    import re
  File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/re.py", line 108, in <module>
    import _locale
SystemError: dynamic module not initialized properly

Under Mac System Python 2.7.10:

Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import naoqi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/naoqi.py", line 9, in <module>
    import qi
  File "/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/qi/__init__.py", line 88, in <module>
    from _qi import Application as _Application
ImportError: dlopen(/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/_qi.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/2.7/Python
  Referenced from: /Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/_qi.so
  Reason: image not found

I have also added the PYTHONPATH in my ~/.bash_profile:

export PYTHONPATH="$PYTHONPATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib"
export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64"

Could someone advise what to do? Thanks in advance!


Solution

  • I found out the problem. The system Python 2.7.10 came with the Mac OS X doesn't work. I have to download the Python 2.7.10 from the Python website and install that in order to have it work: Python Release Website

    This answer was original posted by Calvin in question see revision 2