当我按照MathWorks页面(https://de.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html)上的说明操作并想要运行命令时
import matlab.engine
发生以下错误:
enter code here
runfile('/media/mattes/data1/dataDMattes/Code/Python/PythonProgram /main.py', wdir='/media/mattes/data1/dataDMattes/Code/Python/PythonProgram')
Reloaded modules: shapely.geometry, shapely.algorithms.cga, fiona.compat, shapely.geometry.polygon, pyproj._proj, shapely.geometry.linestring, _proj, fiona._err, shapely.geometry.base, shapely.ftools, shapely.linref, shapely.ops, shapely.predicates, shapely.wkt, _internal, centerline.io, shapely.geometry.geo, shapely.topology, fiona.ogrext, mlarray, _internal.mlarray_utils, shapely.coords, shapely.affinity, shapely.geometry.collection, matlab, shapely.geometry.proxy, centerline.utils, shapely.ctypes_declarations, mlexceptions, fiona.rfc3339, fiona._geometry, shapely, _internal.mlarray_sequence, fiona._drivers, fiona.drvsupport, fiona, shapely.geometry.multipoint, pyproj, shapefile, shapely.speedups, centerline.main, shapely.algorithms, shapely.speedups._speedups, shapely.geometry.multipolygon, pyproj.datadir, shapely.geometry.point, fiona.errors, shapely.impl, shapely.geometry.multilinestring, fiona.collection, shapely.geos, shapely.errors, centerline
Traceback (most recent call last):
File "<ipython-input-2-820f256278b1>", line 1, in <module>
runfile('/media/mattes/data1/dataDMattes/Code/Python/PythonProgram/main.py', wdir='/media/mattes/data1/dataDMattes/Code/Python/PythonProgram')
File "/usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 88, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/media/mattes/data1/dataDMattes/Code/Python/PythonProgram/main.py", line 42, in <module>
import matlab.engine
File "/home/mattes/.local/lib/python3.5/site-packages/matlab/engine/__init__.py", line 62, in <module>
'MathWorks Technical Support for assistance: %s' % e)
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/MATLAB/R2018a/extern/engines/python/dist/matlab/engine/glnxa64/../../../../../../../bin/glnxa64/libmwengine_api.so)
我还尝试重新安装Matlab引擎,并使用Mathworks(python setup.py install
)中建议的命令代替以下命令:
python setup.py build --build-base=$(mktemp -d) install
我使用Python 3.5.2并安装了Ubuntu 16.04中的MATLAB R2018a。
有人有想法吗?
非常感谢你的帮助!
答案 0 :(得分:0)
未找到GLIBCXX_3.4.22
您可以在{例如}中解压缩libstdc++.so.6 -> libstdc++.so.6.0.22
。您的$ HOME,并在运行命令时包含它:示例→
export LD_LIBRARY_PATH=/home/[name]/libstdc++6_6.3.0_amd64:$LD_LIBRARY_PATH && import matlab.engine
什么是...... [命令]
[command]表示与$ HOME中的libstdc++.so.6
一起使用的“任何命令”。
关于文件夹libstdc ++ 6_6.3.0_amd64 /:您可以重命名为例如lib64
文件名较短:/ home / [name] / lib64 /→
export LD_LIBRARY_PATH=/home/[name]/lib64:$LD_LIBRARY_PATH && import matlab.engine