python - 从 Matlab 运行 python 脚本 - 无法加载 matplotlib

标签 python matlab matplotlib

所以我需要从 matlab 运行 python 脚本。这个 python 脚本加载 matplotlib,这似乎是一个问题。我已复制电子邮件末尾的错误。

详细信息

  1. 平台 - Linux
  2. 当我从终端执行这个 python 脚本时,它运行良好。
  3. 当我从不使用 matplotlib 的 matlab 执行另一个 python 脚本时,我似乎没有问题。
  4. ma​​c 上,我的一个 friend 能够通过将命令修改为

    从 matlab 运行脚本

    syscmd = sprintf('export DYLD_LIBRARY_PATH=""; python sim/loglike.py %s %s', 'sim/queryIn_0515-161222', 'sim/temp.txt'), system(syscmd)

请给我任何关于这方面的指示。我无法通过 Google 找到解决方案

最好的,

>> syscmd = sprintf('python sim/loglike.py %s %s', 'sim/queryIn_0515-161222', 'sim/temp.txt'), system(syscmd)

syscmd =

python sim/loglike.py sim/queryIn_0515-161222 sim/temp.txt

Traceback (most recent call last):
  File "sim/loglike.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/pyplot.py", line 26, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/figure.py", line 34, in <module>
    import matplotlib.colorbar as cbar
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/colorbar.py", line 29, in <module>
    import matplotlib.collections as collections
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/collections.py", line 23, in <module>
    import matplotlib.backend_bases as backend_bases
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 37, in <module>
    import matplotlib.widgets as widgets
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/widgets.py", line 17, in <module>
    from lines import Line2D
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/lines.py", line 25, in <module>
    from matplotlib.font_manager import FontProperties
  File "/opt/python27/lib/python2.7/site-packages/matplotlib/font_manager.py", line 53, in <module>
    from matplotlib import ft2font
ImportError: /opt/matlab/7.13/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /opt/python27/lib/python2.7/site-packages/matplotlib/ft2font.so)

ans =

     1

最佳答案

Matlab 不使用系统库(它设置 LD_LIBRARY_PATH 变量)。试试这个:

system('LD_LIBRARY_PATH='''' python my_script.py')

关于python - 从 Matlab 运行 python 脚本 - 无法加载 matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23704095/

相关文章:

python - 变色龙模板 : Default value in 'tal:switch'

python - Ipython笔记本水平缩放

algorithm - 雅可比法的两种算法 : why the time change?

python - 在 Tkinter 中更改 matplotlib 的导航工具栏大小

python - FFmpeg Drawbox 和 ZMQ b'38 功能未实现'

java - Gson 没有将带有 unicode 前缀的字符串映射到 java 对象

python - 在 numpy 中计算距离的更有效方法?

python - 像 Matlab 的 delsq 演示中那样将 ndarray 转换为矢量映射的 numpy 方法?

python - 为什么 plt.imshow 比 plt.pcolor 快得多?

python - 如何在 wxpython 面板中重绘 mathplotlib 图形?