Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So I need to run a python script from matlab. This python script loads matplotlib and this seems to be a problem. I've copied the error at the end of the email.

Details

  1. Platform - Linux
  2. When I just execute this python script from the terminal, it runs fine.
  3. When I execute another python script from matlab which doesn't use matplotlib, I don't seem to have a problem.
  4. On a mac, one of my friends was able to run the script from matlab by modifying the command to

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

Please give me any pointers on this. I couldn't find a solution via Google

best,

>> 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
share|improve this question
    
It's an issue of environment variables. I don't know which one is modified or set by matlab on linux, but this one points your python installation to use some libraries within the matlab directory instead of the OS default. Try running printenv via Matlab and directly via shell. Maybe you find the right one to restore the same way your friend did, otherwise add the information to your question. –  Daniel May 16 at 22:47

1 Answer 1

Matlab does not use the system libraries (it sets the LD_LIBRARY_PATH variable). Try this instead:

system('LD_LIBRARY_PATH='''' python my_script.py')
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.