问题
I have been trying to build .exe file using pyinstaller in windows 10. It worked, but the size of the exe file is ~212 MB, even by using a venv (as in here). I thought it might be because I am using python by anaconda!
Then I installed a separate version of Python so not to use anaconda! But it did not work (still large file).
Then I uninstalled anaconda to test it. Pyinstaller is still trying to access Python in 'C:\Program Files\anaconda3\python.exe' (this error: No Python at 'C:\Program Files\anaconda3\python.exe'). However I have removed all path to anaconda. Probably it has always tried to reach anaconda, and this is why I haven't been successful to build a small size .exe file.
How can I clearly indicate paths for pyinstaller and python?
回答1:
Finally, after a lot of researching, could solve my problem:
- Uninstalled all pythons and anaconda from my PC
- Removed all Path from the system variables
- Restarted the windows
- Installed a fresh Python from its website
- Installed Pyinstaller using pip install pyinstaller
- Tested my .py code in cmd. It showed me all the packages that are missing.
- Installed all required packages by using pip install name-of-package
- Ran final command by pyinstaller -F -w --clean file.py
- (Optional) Install Anaconda if you need (don't add Anaconda Python as the default python. Also don't add its path to the system variables).
My previous tries which used anaconda resulted in file of 212 MB in size. This process generated a .exe file of size 27 MB (Importing only pandas module).
来源:https://stackoverflow.com/questions/59524507/how-to-make-pyinstaller-not-use-anaconda-and-build-a-small-size-exe-file