38

I am trying to use pyinstaller in cmd but I receive error:

C:\Users\username>pyinstaller
'pyinstaller' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\username>

When I use this command in the Scripts folder in python , it works:

C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts>pyinstaller
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
                   [--add-data <SRC;DEST or SRC:DEST>]
                   [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
                   [--hidden-import MODULENAME]
                   [--additional-hooks-dir HOOKSPATH]
                   [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
                   [--key KEY] [-d] [-s] [--noupx] [-c] [-w]
                   [-i <FILE.ico or FILE.exe,ID or FILE.icns>]
                   [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
                   [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
                   [--win-no-prefer-redirects]
                   [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                   [--distpath DIR] [--workpath WORKPATH] [-y]
                   [--upx-dir UPX_DIR] [-a] [--clean] [--log-level LEVEL]
                   [--upx UPX]
                   scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname

C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts>

How to solve this?

user8533214
  • 391
  • 1
  • 3
  • 4

19 Answers19

40

I did correctly configured my script path, I had to run python -m PyInstaller script.py in order for it to work

For every script I have to follow this pattern, python -m [script name] [args]

python version 3.10.0

PJ3
  • 3,870
  • 1
  • 30
  • 34
37

You have to modify your User PATH environment variable to include C:\Users\[USERNAME]\AppData\Local\Programs\Python\Python36-32\Scripts.

For how to add/modify your PATH environment variables, see this.

Justin
  • 49
  • 1
  • 1
  • 6
user10089632
  • 5,216
  • 1
  • 26
  • 34
  • you can shorten the path like so - `%LocalAppData%\Programs\Python\Python36-32\Scripts` – Gangula Nov 28 '22 at 09:47
  • but the folder was in `AppData/roaming` folder for me instead of `Appdata/local`. So I used - `%AppData%\Python\Python311\Scripts` – Gangula Nov 28 '22 at 09:48
9

First, you need to know where is the pyinstaller locates. In my case, I ran

pip uninstall pyinstaller

Before it's being uninstalled, it will ask you to confirm if you want to remove the following file...

c:\users\USERNAME\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\scripts\pyinstaller.exe

Great! Now by doing this, you know your path to pyinstaller. Simple type 'No' and exit the uninstallation as our purpose is just to get the path. Now just add this path to the PATH variable.

c:\users\USERNAME\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\scripts\

For how to change your PATH variable. Check here

David
  • 826
  • 6
  • 4
8

For Python 3.7, you will have to add the Scripts folder from AppData/Roaming (%appdata%) to the PATH variable.

C:\Users\%USERNAME%\AppData\Roaming\Python\Python37\Scripts

Elijah
  • 1,814
  • 21
  • 27
8

Copy 'pyinstaller.exe' to the folder you have the .py file you want to convert. When you are done, just delete 'pyinstaller.exe'. Good luck.

Manan
  • 161
  • 1
  • 5
  • 1
    moving an executable around is really cumbersome if you need it often, setting the path variable is much more elegant – Plegeus Jul 23 '23 at 20:36
5

This solution work for Python 3.9

First of all find the pyinstaller.exe location. To do this you could try this trick: (do not press 'y' just look at the above copy the path what you are looking for)

pip uninstall pyinstaller

Before typing anything, it will show you the path where the pyinstaller.exe is. After that copy the location and run this command on terminal: (it is an example)

python C:\Users\[YOUR_USER_NAME]\AppData\...Scripts\pyinstaller.exe --onefile [your_script_name.py]
Twister Joe
  • 111
  • 2
  • 11
3

Goto - "C:\Users\Username\anaconda3\Scripts" path and copy "pyinstaller.exe" and paste it in the directory where you want to use pyinstaller, it worked for me

2

I found How we should fix this error :

C:\Users\username>pyinstaller
'pyinstaller' is not recognized as an internal or external command,
operable program or batch file.

We should enter this code in cmd pip install pyinstaller if it is doesn't work again you should go C:/user/pc name/Appdata (Appdata folder is hide)/python now you should copy script folder and C:/program files/python39 and copy site package to C:/program files/python39/lib

then if you type pyinstaller in cmd you see it work

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40
Amir
  • 31
  • 1
2

Oddly, for me changing the capitalization resolved the issue. I typed python -m [scriptname] [args]. In [scriptname] I typed PyInstaller instead of pyinstaller and it actually worked. I tried both ways multiple times.

BoyAcc
  • 193
  • 7
1

Copy youe script folder's path C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts and paste it in: environment varibales> system varibales> path and save it. Then restart your PC and try running pyinsatller from anywhere it will work.

pratham82
  • 43
  • 1
  • 6
1

Had exactly the same issue:

  • Locate your Python folder and go to Python\Python38\Lib\site-packages
  • From there delete the Pyinstaller module and Pyinstaller dis.info folder
  • Reinstall Pyinstaller using pip install pyinstaller
Jesse
  • 2,043
  • 9
  • 28
  • 45
Nizorrro
  • 21
  • 1
1
  1. Open command cmd from this path: ctrl+r, write "cmd" in box
  2. Uninstall pyinstaller: pip uninstall pyinstaller
  3. Install it again: pip install pyinstaller
  4. Use the pyinstaller by writing pyinstaller
Dan R
  • 1,412
  • 11
  • 21
AT160
  • 19
  • 1
1

If you are using python 3.10 or higher, chance are that the pyinstaller is not added to your Path variables. To avoid all of that setup, you can simply run

python -m PyInstaller [path to your file] [args]

For example I ran

python -m PyInstaller ./frontend.py --onefile
Faraz Zaidi
  • 103
  • 8
0

if you cannot do anything or you have less time, you can make the virtual environment and install pyinstaller there, then generate executable file

0

Enter in Administrative Console: pip install pyinstaller

0

First, you should check the configuration, ports, and active process.

After checking these processes, you can check the local folder.

You will find the pyinstaller inside this folder; there will be a pyinstaller.exe file.

Then set the path

C:\Users\[username]\AppData\Local\Programs\Python\Python39\Scripts,

C:\Users\[username]\AppData\Local\Programs\Python\Python39.

After that, you can run the command pyinstaller --onefile -w filename.py

iamzeid
  • 104
  • 1
  • 2
  • 18
0

If installing pyinstaller and creating the 'path' variables still does not work, u can use this workaround:

Locate pyinstaller.exe from possible python directory like C:\Users\ "UserName" \AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts

Copy it to the dir that you have the .py file you want to compile as .exe

Use following command in terminal: .\pyinstaller --onefile YOUR_FILE_NAME.py

0

For me and on python version 3.9.12 the below command worked. The 'P' and 'I' in PyInstaller is capital. Also, I reinstalled the python package. Please see below the steps.

  1. python -m pip uninstall pyinstaller -- for uninstalling the python package
  2. python -m pip install pyinstaller -- for installing the python package
  3. python -m PyInstaller -- and followed by rest of the attributes.
Rishabh Aher
  • 61
  • 2
  • 7
  • The capitals do not matter in the first two commands, since [PyPi is case insensitive](https://stackoverflow.com/questions/26503509/is-pypi-case-sensitive). For the last command it does matter indeed, but there's nothing new to your post. Calling PyInstaller this way is already [answered here](https://stackoverflow.com/a/69780822/10669875). Reinstalling the package is also mentioned a few times already. If you post an answer to an old question with 18 answers already, please make sure your answer adds something new, and explain what's new in your answer. – wovano Jul 01 '22 at 07:13
-1

If you don't have pip in the PATH of your cmd, then you can run these commands in cmd for windows.

  1. python -m pip install pyinstaller - for installing pyinstaller.
  2. python -m pip uninstall pyinstaller - for uninstalling pyinstaller.
wp78de
  • 18,207
  • 7
  • 43
  • 71