I am trying to compile a python script using pyinstaller with modules like scientific,MMTK. Pyinstaller was unable to include some .pyd modules so I copied them manually in the dist folder. When I executed the compiled exe it gave me following error:-
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'
BTW I can see the outPYZ1.pyz file at that location. Any idea?
It’s not about pyd files, but about a TGA file not found. You need to adapt your software to look at a different location when the application is packaged by pyinstaller. According to Accessing to data files:
So, if you open a file in your program, don’t do:
This method is opening the file from the current directory. So it will just not work for pyinstaller, because the current directory will be not the same than where the data will be put.
Depending if you are using
--onefile, you must change to:Or if it’s
--onedir: