我正在使用Python 3.4.3 | OS X 10.10.5和后续的these instructions to install MATLAB Engine for Python上的Anaconda 2.3.0(x86_64)。安装似乎,但在启动蟒蛇&尝试导入成功,我看到了以下内容:使用Anaconda安装“用于Python的MATLAB引擎”的问题
Python 3.4.3 |Anaconda 2.3.0 (x86_64)| (default, Oct 20 2015, 14:27:51)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matlab.engine
Traceback (most recent call last):
File "/Users/tyler/.local/lib/python3.4/site-packages/matlab/engine/__init__.py", line 42, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/Users/tyler/anaconda/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'matlabengineforpython3_4'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/tyler/.local/lib/python3.4/site-packages/matlab/engine/__init__.py", line 58, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/Users/tyler/anaconda/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "<frozen importlib._bootstrap>", line 539, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1715, in load_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
ImportError: dlopen(/Applications/MATLAB_R2015b.app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_4.so, 2): Library not loaded: @rpath/libpython3.4m.dylib
Referenced from: /Applications/MATLAB_R2015b .app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_4.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tyler/.local/lib/python3.4/site-packages/matlab/engine/__init__.py", line 60, in <module>
raise EnvironmentError('The installation of MATLAB Engine for Python is '
OSError: The installation of MATLAB Engine for Python is corrupted. Please reinstall it or contact MathWorks Technical Support for assistance.
在研究这个问题,我发现severalotherreferences到MathWorks的网站这个确切的问题,都没有解决。最后的链接表明问题可能在dynamic linking。
鉴于许多科学工具箱如何只在MATLAB可用,这将是很有用处的能够调用使用蟒蛇这种发动机。虽然有其他可用的软件包可以支持这种功能,但它们总是具有局限性或其他复杂性,如客户机 - 服务器体系结构。
任何建议是最受欢迎的。
如果我发现了这个一周前回答! :-)除了添加这个所有重要的链接外,重要的是LD_LIBRARY_PATH不包含anaconda的路径。对于OS X用户来说DYLD_LIBRARY_PATH也是如此......请参阅完整的Anaconda/MATLAB指令,这些指令适用于我:https://stackoverflow.com/a/45161288/2524427 – 5Ke
对于那些在macOS上使用pyenv的人: 'sudo ln -s $ HOME/.pyenv/versions/3.4.7/Python.framework/Versions/3.4/lib/libpython3.4m.dylib/usr/local/lib' –