필터 지우기
필터 지우기

Matlab engine for python import failure

조회 수: 3 (최근 30일)
Degang
Degang 2015년 6월 2일
댓글: Evan 2015년 8월 12일
Mac OS X 10.10.3, Python 3.4.3, Matlab2015a.
I installed the matlab engine for python according to the instruction found here. However, whenever I try to import matlab.engine in python, I will get the following error message:
Python 3.4.3 (default, Apr 7 2015, 08:05:21)
Type "copyright", "credits" or "license" for more information.
IPython 3.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: MacOSX
In [1]: import matlab.engine
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/local/lib/python3.4/site-packages/matlab/engine/__init__.py in <module>()
40 try:
---> 41 pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
42 except:
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/__init__.py in import_module(name, package)
108 level += 1
--> 109 return _bootstrap._gcd_import(name[level:], package, level)
110
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _gcd_import(name, package, level)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _find_and_load(name, import_)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
ImportError: No module named 'matlabengineforpython3_4'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
/usr/local/lib/python3.4/site-packages/matlab/engine/__init__.py in <module>()
56 os.environ[_envs[_arch]] = _bin_dir
---> 57 pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
58 except:
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/__init__.py in import_module(name, package)
108 level += 1
--> 109 return _bootstrap._gcd_import(name[level:], package, level)
110
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _gcd_import(name, package, level)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _find_and_load(name, import_)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _load_unlocked(self)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _load_backward_compatible(self)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _check_name_wrapper(self, name, *args, **kwargs)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in load_module(self, fullname)
/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
ImportError: dlopen(/Applications/MATLAB_R2015a.app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_4.so, 2): Library not loaded: @rpath/libpython3.4m.dylib
Referenced from: /Applications/MATLAB_R2015a.app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_4.so
Reason: image not found
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-1-7ec811bb5400> in <module>()
----> 1 import matlab.engine
/usr/local/lib/python3.4/site-packages/matlab/engine/__init__.py in <module>()
57 pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
58 except:
---> 59 raise EnvironmentError('The installation of MATLAB Engine for Python is '
60 'corrupted. Please reinstall it or contact '
61 'MathWorks Technical Support for assistance.')
OSError: The installation of MATLAB Engine for Python is corrupted. Please reinstall it or contact MathWorks Technical Support for assistance.

채택된 답변

Bo Li
Bo Li 2015년 6월 2일
The error message "Library not loaded: @rpath/libpython3.4m.dylib" indicates that the Python library is not found. Are you able to find the file "libpython3.4m.dylib" in folder "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/"?
If so, you can try to set the environment variable DYLD_LIBRARY_PATH. In csh, this is the command:
setenv DYLD_LIBRARY_PATH /usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/
  댓글 수: 1
Evan
Evan 2015년 8월 12일
This did not work for me:
>>> import os
>>> os.environ['DYLD_LIBRARY_PATH'] = '/Users/Evan/miniconda/lib/'
>>> import matlab.engine
Traceback (most recent call last):
File "/Users/Evan/miniconda/lib/python3.4/site-packages/matlab/engine/__init__.py", line 41, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/Users/Evan/miniconda/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/Evan/miniconda/lib/python3.4/site-packages/matlab/engine/__init__.py", line 57, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/Users/Evan/miniconda/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_R2015a.app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_4.so, 2): Library not loaded: @rpath/libpython3.4m.dylib
Referenced from: /Applications/MATLAB_R2015a.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/Evan/miniconda/lib/python3.4/site-packages/matlab/engine/__init__.py", line 59, 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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by