如果这不是提出这个问题的最佳场所,我深表歉意,但希望这里有人可以提供帮助。我想直接从 Sage 脚本中运行一些 gnuplot 命令,但我收到以下错误消息:
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
如果我尝试在 Sage 中使用 gnuplotpy 界面,或者如果我只是使用 Sage 中的 os.system("gnuplot -e\"plot('sin(x)')\"") 之类的东西,就会出现此消息。但是,相同的 os.system(...) 命令在常规 python 中工作得很好。非常感谢。
请您参考如下方法:
Sage 更改了许多环境,包括 PATH、LD_LIBRARY_PATH 等。这可能导致运行未安装在 Sage 中的二进制文件时出现问题。出于这个原因,它提供了一个 shell 命令 sage-native-execute ,它(大部分)将所有变量改回原样。所以请尝试以下操作——它解决了我的问题:
os.system('''sage-native-execute gnuplot -e "plot('sin(x)')"''')
