I\'m working in Windows, using PyInstaller
to package a python file. But some error is occuring:
Traceback (most recent call last):
File \"<
You can add the path to your application spec file.
In the Analysis object you can specify pathex=['C:\Python27\libs\', 'C:\Python27\Lib\site-packages']
, and any other path ...
Note that if the path is not found there is no problem ... I have paths from linux as well in there.
This sounds like a job for hidden imports (only available in the latest builds).
From the docs
a = Analysis(['myscript.py'],
hiddenimports = ['_socket'],
<and everything else>)
Had similar issues. Here's my fix for PyQt5, cffi, python 3.4.3:
This fixes the 'sip' not found error and the '_cffi_backend' one if that comes up:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['LightShowApp.py'],
pathex=['c:\\MyProjects\\light-show-editor-36',
'c:\\Python34\\libs\\', 'c:\\Python34\\Lib\\site-packages'],
binaries=None,
datas=None,
hiddenimports=['sip', 'cffi'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='LightShowApp',
debug=False,
strip=False,
upx=True,
console=True )
Look at 'pathex' and 'hiddenimports' above. Those are the only changes from default generated. Build exe with:
pyinstaller LightShowApp.spec -F
I ran that outside of venv or pip-win - whateverTF that crap is for!
In my case, I had to delete all folders and files related to pyinstaller
in my directory, i.e. __pycache__
, build
, dist
, and *.spec
. I re-ran the build and the exe worked.
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
None of the above answers worked for me, but I did get it to work. I was using openpyxl and it required jdcal in the datetime.py module. None of the hidden imports or any of those methods helped, running the exe would still say jdcal not found. The work-around that I used was to just copy the few functions from jdcal directly into the datetime.py in the openpyxl code. Then ran
pyinstaller -F program.py
and it worked!