简体   繁体   中英

The Exe file that was build with python installer does not work now

I was build one exe file with python installer. The code is using numpy package and pyqt UI builder. I installed numpy in virtulal environment of my working folder. It is working in python script, then I build it as Exe file, then it is not working.

enter image description here

please help me if you know about the issue. Thanks

While using pyinstaller to convert.py file to.exe having large dependencies (like numpy, pandas) following these steps would solve the ModuleNotFound error:

  1. Install the PIP packages in the project directory

  2. Change the hook file
    Navigate to \venv\Lib\site-packages\PyInstaller\hooks
    If there is a hook-numpy.py file, edit the script to:

from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules('numpy._libs')
  1. Before converting to.exe file, make.spec file using the following command:
pyi-makespec — onefile program_name.py
  1. Edit the.spec file (open using notepad)
    append the libraries to the hiddenimports list
...
hiddenimports = ['numpy']
...
  1. Compile the script using the.spec file with the following command:
pyinstaller — onefile program_name.spec

Finally, find the.exe file in the dist folder, and run it.

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