简体   繁体   中英

How to convert Python project into executable

I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.

The command line I used with success is:

pyinstaller --noupx --onefile --add-data="cprofiles.ui;." cprofiles_lmfit.py

pyinstaller manages relatively well the multiple '.py' files that you import, no need to cite them. Under the 'add-data' option, you list the non-py files and in my example, the 'cprofiles_lmfit.py' file is the one containing the main.

But as indicated here need help to compile python with pyinstaller (and in few other posts), I am a beginner with pyinstaller. I was never able to use the 'theano' module and I did not optimize. I still have to test the suggestions in the answer.

1) Open the command prompt

2) Install pyinstaller Pip install pyinstaller

3) Test your python script first just to check python script should work with normal .py extension. Saurabh is the name of python file python saurabh.py

4) Convert the python into executable file pyinstaller --onefile Saurabh.py

Notice we have passed “–onefile” as a argument which tell pyinstaller to create only one file

5) Go to directory and navigate to the dist folder.

Prerequisite : Install PyQt5 to avoid error. pip install PyQt5

将主脚本转换为.exe应该可以解决该问题,请使用-onefile将其转换为一个exe,其余的.py文件应包括在内。

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