mah65
mah65

Reputation: 588

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 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?

Upvotes: 2

Views: 8188

Answers (2)

Joseph
Joseph

Reputation: 663

I ran into a similar problem and found PyCharms virtualenv manager very helpful. https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html

This just necessitated downloading python from python.org and linking the virtual environment to this interpreter, rather than the conda interpreter (otherwise it will throw strange SSL errors).

This seems to allow neat parallel use of conda and virtualenv.

Upvotes: 0

mah65
mah65

Reputation: 588

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

Upvotes: 8

Related Questions