Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
771 views
in Technique[技术] by (71.8m points)

python - How to make pyinstaller not use anaconda and build a small-size exe file

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 Filesanaconda3python.exe' (this error: No Python at 'C:Program Filesanaconda3python.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).

Note: You can build virtualenv and do pyinstaller in them.

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...