I'm working in Windows, using PyInstaller
to package a python file. But some error is occuring:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "D:\Useful Apps\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "D:\Useful Apps\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "D:\Useful Apps\pyinstaller-2.0\server\build\pyi.win32\server\out00-PYZ.pyz\SocketServer", line 132, in <module>
File "D:\Useful Apps\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "D:\Useful Apps\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "D:\Useful Apps\pyinstaller-2.0\server\build\pyi.win32\server\out00-PYZ.pyz\socket", line 47, in <module>
File "D:\Useful Apps\pyinstaller-2.0\PyInstaller\loader\iu.py", line 409, in importHook
raise ImportError("No module named %s" % fqname)
ImportError: No module named _socket
I know that _socket
is in path C:\Python27\libs\_socket.lib
, but how can let the generated EXE
find that file?
If you are using virtualenv you should use the "-p" or "--path='D:...'" option. Like this:
pyinstaller.exe --onefile --paths=D:\env\Lib\site-packages .\foo.py
What this does is generates foo.spec file with this pathex path
If you are using an virtual environment, then problem is because of environment.
SOLUTION Just activate the environment and run the pyinstaller command. For example, If you are using environment of pipenv then run commands in following order.
pipenv shell # To activate environment
pyintaller --onefile youscript.py # Command to generate executable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With