4
因此,我已经编译了一个py2exe的python脚本,根据this answer。编译期间没有错误,一切都很顺利。运行编译的Python脚本的问题
当我运行从一个cmd这样的脚本:
C:\Users\Richard\Dist\backprop3.exe 60
这是输出我得到:
C:\Users\Richard>C:\Users\Richard\Dist\backprop3.exe 60
Traceback (most recent call last):
File "backprop3.py", line 209, in <module>
File "backprop3.py", line 175, in demo
NameError: global name '__file__' is not defined
C:\Users\Richard>
这是指这条线:
image = Image.open(os.path.dirname(os.path.abspath(__file__))+"/backprop-input.bmp")
该行只从当前目录加载图像。哪里有问题?