The error "'pyinstaller' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:
pyinstallermodule without having it installed.
Make sure you have pyinstaller
installed by running the following command in
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 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
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
Shiftand 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 virtual environment pip install pyinstaller
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
pyinstallermodule is installed by using the
pip show pyinstallercommand.
pip show pyinstaller pip3 show pyinstaller python -m pip show pyinstaller py -m pip show pyinstaller python3 -m pip show pyinstaller
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.
Note that I have Python 3.10 installed, which is reflected in the PATH.
Scriptsdirectory that is located in your Python3X folder. This is where the executable files are located.
For me, it is the following path.
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:
pyinstallermodule installed before using it.