cjohnson
cjohnson

Reputation: 149

Error using gnuplot from within Sage, but works fine in regular Python

I apologize if this isn't the best place to ask this question, but hopefully someone here can help. I want to run some gnuplot commands directly from within a Sage script, but I get the following error message:

dyld: Library not loaded: /opt/local/lib/libfreetype.6.dylib Referenced from: /opt/local/bin/gnuplot Reason: Incompatible library version: gnuplot requires version 14.0.0 or later, but libfreetype.6.dylib provides version 10.0.0

This message appears if I try to use the gnuplotpy interface in Sage, or if I just use something like os.system("gnuplot -e \"plot('sin(x)')\"") from Sage. However, the same os.system(...) command works just fine in regular python. Many thanks.

Upvotes: 2

Views: 218

Answers (1)

Ivan Andrus
Ivan Andrus

Reputation: 5301

Sage changes a number of environments including PATH, LD_LIBRARY_PATH, etc. This can cause problems running binaries not installed inside Sage. For this reason it provides a shell command sage-native-execute which (mostly) changes all the variables back. So try the following—it fixes the problem for me:

os.system('''sage-native-execute gnuplot -e "plot('sin(x)')"''')

Upvotes: 1

Related Questions