我正在尝试使用pyinstaller和scientific、MMTK等模块编译python脚本。Pyinstaller无法包含一些.pyd模块,因此我在dist文件夹中手动复制了它们。当我执行编译后的exe时,它给了我以下错误:
C:\Python27\hello\dist\hello>hello.exe Traceback (most recent call last): File "", line 21, in File "C:\Python27\iu.py", line 436, in importHook mod = _self_doimport(nm, ctx, fqname) File "C:\Python27\iu.py", line 521, in doimport exec co in mod.__dict__ File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/visual", line 1, in <module> File "C:\Python27\iu.py", line 436, in importHook mod = _self_doimport(nm, ctx, fqname) File "C:\Python27\iu.py", line 521, in doimport exec co in mod.__dict__ File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/visual.visual_all", line 1, in <module> File "C:\Python27\iu.py", line 436, in importHook mod = _self_doimport(nm, ctx, fqname) File "C:\Python27\iu.py", line 521, in doimport exec co in mod.__dict__ File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis", line 13, in <module> File "C:\Python27\iu.py", line 436, in importHook mod = _self_doimport(nm, ctx, fqname) File "C:\Python27\iu.py", line 521, in doimport exec co in mod.__dict__ File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis.ui", line 3, in <module> File "C:\Python27\iu.py", line 477, in importHook mod = self.doimport(nm, ctx, ctx+'.'+nm) File "C:\Python27\iu.py", line 521, in doimport exec co in mod.__dict__ File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis.materials", line 159, in <module> File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis.materials", line 129, in loadTGA IOError: [Errno 2] No such file or directory: 'c:\\Python27\\hello\\build\\pyi.win32\\hello\\outPYZ1.pyz/turbulence3.tga'
顺便说一下,我可以在那个位置看到outbyz1.pyz文件。知道吗?
不是关于pyd文件,而是关于找不到TGA文件。当应用程序由pyinstaller打包时,您需要调整软件以查看不同的位置。根据Accessing to data files:
因此,如果在程序中打开文件,请不要执行以下操作:
此方法正在从当前目录中打开文件。所以它对pyinstaller不起作用,因为当前目录与数据的存放位置不同。
根据您使用的是
--onefile
,您必须更改为:或者如果是
--onedir
:相关问题 更多 >
编程相关推荐