简体   繁体   中英

pyinstaller cannot include package

I run python 2.7 in a virtual environment in which running pip freeze after activating it returns

future==0.17.1
lz4==2.1.6
pyparsing==2.3.1
PyQt4 @ file:///C:/.../PyQt4-4.11.4-cp27-cp27m-win_amd64.whl
xlrd==1.2.0

If I run python in the activated virtual environment and import lz4, it is imported successfully.

However, when I try to build the executable with pyinstaller (3.6 version) without --windowed , running the exe file from cmd gives a ImportError: No module named lz4 .

So I guess that for some reason the pyinstaller cannot include the specific package.

I have tried adding running the pyinstaller command with --hidden-import=lz4 , --paths="path_folder_to_lz4_inside_virtualenv" , including hiddenimports=['lz4'], on the .spec file and running the pyinstaller command on the .spec file instead of the .py file (and on the .py as well), including

from PyInstaller.utils.hooks import collect_submodules

hidden_imports = collect_submodules('lz4')

on the .spec and running the pyinstaller command on both .spec and .py but the ImportError persists.

My machine has Windows 10. Note that this is a cloned virtual environment from another machine where the pyinstaller command run without any problems and the only difference is that I had Windows 7 and PyQt was not installed with a wheel file but with copying PyQt4 folder and sip.pyd from tha base installation to the environment packages folder.

Any suggestions?

Ok a solution in case someone has the same problem.

In the previous machine, were there was no problem, the pyinstaller command run pyinstaller from the main python installation which was python 2.7. (virtual environment didn't have pyinstaller installed)

In the machine were the problem was, the pyinstaller was installed in the main installation (python 3) and in a separate virualenv with a main python 2.7 installation and I run pyinstaller from this python 2.7 installation.

Now I installed pyinstaller on the virtualenv for this specific app and I run the pyinstaller command from there and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM