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

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

我看到有人在这里回答了同样的问题:Python for Naoqi (dynamic module not initialized properly),但我按照页面中的答案进行操作,仍然无法正常工作。有人可以建议如何进行吗?

使用 Python 2.7.10 没有帮助。 在 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

在Mac系统下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

我还在 ~/.bash_profile 中添加了 PYTHONPATH:

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"

有人可以建议该怎么做吗?提前致谢!

我发现了问题。 Python 2.7.10 自带的系统 Mac OS X 不工作。我必须从 Python 网站下载 Python 2.7.10 并安装它才能运行:Python 发布网站

此回答由Calvin in question see revision 2

原创