我正在研究编码矩阵'作者:Philip Klein。在第二章中,有一个绘制复数的例子
from plotting import plot
S = {2+2j, 3+2j, 1.75+1j, 2+1j, 2.25+1j, 2.5+1j, 2.75+1j, 3+1j, 3.25+1j}
plot(S, 4)
绘图模块:http://resources.codingthematrix.com
当我在终端中通过python直接运行代码时,它工作正常,但当我将其作为单独的文件" $ python example.py"运行时,我收到此错误:
gvfs-open: file:///tmp/tmpOYFVs8.html: error opening location: Error
when getting information for file '/tmp/tmpOYFVs8.html': No such file
or directory
不确定如何解决此问题。尝试使用模块代码,但无处可去。
答案 0 :(得分:1)
我检查了plotting.py的代码并发现在代码末尾注册了atexit事件,当程序退出时基本上删除了该文件。所以当你调用它时脚本python intrepreter退出会调用实习生atexit注册删除文件。
def remove_at_exit(path):
atexit.register(os.remove, path)
你可以在第92行的plotting.py中直接注释掉对remove_at_exit方法的调用
答案 1 :(得分:0)
打开plotting.py然后修补此
hpath = os.getcwd() + "/something.html"
相反或在此之后的一行
hpath = create_temp('.html')