Last updated: Apr 4, 2024
Reading timeยท4 min
The error "'pyinstaller' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:
pyinstaller
module without having it installed.Make sure you have pyinstaller
installed by running the following command in cmd
.
pip install pyinstaller # ๐๏ธ for Python 3 pip3 install pyinstaller # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install pyinstaller # ๐๏ธ using py alias py -m pip install pyinstaller # ๐๏ธ for Python 3 python3 -m pip install pyinstaller # ๐๏ธ If you get a permissions error pip install pyinstaller --user
You should now be able to use the pyinstaller
command as follows.
pyinstaller your_program.py python -m pyinstaller your_program.py py -m pyinstaller your_program.py python 3 -m pyinstaller your_program.py
If the installation command doesn't succeed, try running CMD as an administrator.
To open CMD as an administrator:
Click on the Search bar and type CMD.
Right-click on the Command Prompt application and click "Run as administrator".
You can also try to upgrade the package with the --upgrade
option.
python -m pip install pyinstaller --upgrade py -m pip install pyinstaller --upgrade python3 -m pip install pyinstaller --upgrade
Alternatively, you can install the pyinstaller
module in a virtual
environment:
Shift
and right-click in Explorer.# ๐๏ธ might also be: "python3 -m venv venv" python -m venv venv # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ install pyinstaller in the virtual environment pip install pyinstaller
If the python -m venv venv
command doesn't work, try the following 2 commands:
py -m venv venv
.python3 -m venv venv
If you see an error message that "ps1 cannot be loaded because running scripts is disabled on this system", run the following command, type "yes" when prompted and rerun the activation command.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
pyinstaller
module is installed by using the pip show pyinstaller
command.pip show pyinstaller pip3 show pyinstaller python -m pip show pyinstaller py -m pip show pyinstaller python3 -m pip show pyinstaller
The pip show pyinstaller
command will either state that the package is not
installed or show a bunch of information about the package, including the
location where the package is installed.
If the error persists, you have to add Python to your user's PATH environment variable.
To add Python to your user's PATH environment variable:
python -c "import os, sys; print(os.path.dirname(sys.executable))" where python
For me, the path is the following.
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310
Note that I have Python 3.10 installed, which is reflected in the PATH.
Scripts
directory that
is located in your Python3X folder. This is where the executable files are
located.For me, it is the following path.
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts
You might also have to restart your PC, but that's not always necessary.
If you still encounter issues, try to add Python to your PATH using the official installer.
Download the installer from the official python.org website.
If you have Python already installed, start the installer and click on "Modify".
You can leave the optional features ticked.
If that didn't work, your Python installation might be corrupted.
Start the installer again and click on "Uninstall".
Now that you don't have Python installed on your machine, start the installer again and make sure to tick the "Add python.exe to PATH" option.
The checkbox won't be checked by default.
Once the "Add python.exe to PATH" checkbox is checked, click on "Install Now".
After the installation, Python will be installed and configured properly.
To solve the error "'pyinstaller' is not recognized as an internal or external command, operable program or batch file", make sure:
pyinstaller
module installed before using it.