Skip to content Skip to sidebar Skip to footer

How To Specify Python Version And Library Versions For Pyinstaller Executable

When creating an executable file using PyInstaller, how can I bundle a specific Python interpreter and some library from specific versions? I want to create an executable file from

Solution 1:

I do this using virtual environments: if you have an environment with the desired Python version and package versions, you can pip install PyInstaller there and build the .EXE from that environment.

The Conda version would be:

  1. Create the environment:
conda create--name my_env_name python=3.6
  1. Activate it:
conda activate my_env_name
  1. Install your desired package versions and PyInstaller:
pip install pandas==0.23
pip install beautifulsoup4==4.9.1
pip install pyinstaller

# or to get the developer version, which fixes some issues I have run into# pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
  1. And then build your EXE:
python pyinstaller myscript.py

Having this virtual environment can be a nice control as well for writing/testing your program, as it ensures no other dependencies are needed. Because of this, I tend to only install the necessary packages for the script into the environment.

However, I am not sure how one would do this with venv, if you do not have Anaconda. But maybe this will still point you in a direction (or someone else can elaborate? also see this post).

Post a Comment for "How To Specify Python Version And Library Versions For Pyinstaller Executable"