I am trying to use pyinstaller in cmd but I receive error:
C:Usersusername>pyinstaller 'pyinstaller' is not recognized as an internal or external command, operable program or batch file. C:Usersusername>
When I use this command in the Scripts folder in python , it works:
C:UsersusernameAppDataLocalProgramsPythonPython36-32Scripts>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:UsersusernameAppDataLocalProgramsPythonPython36-32Scripts>
How to solve this?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You have to modify your User PATH environment variable to include C:Users[USERNAME]AppDataLocalProgramsPythonPython36-32Scripts.
For how to add/modify your PATH environment variables, see this.
Method 2
For Python 3.7, you will have to add the Scripts folder from AppData/Roaming (%appdata%) to the PATH variable.
C:Users%USERNAME%AppDataRoamingPythonPython37Scripts
Method 3
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
Method 4
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.
Method 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...Scriptspyinstaller.exe --onefile [your_script_name.py]
Method 6
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:usersUSERNAMEappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39scriptspyinstaller.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:usersUSERNAMEappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39scripts
For how to change your PATH variable. Check here
Method 7
Copy youe script folder’s path C:UsersusernameAppDataLocalProgramsPythonPython36-32Scripts 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.
Method 8
Had exactly the same issue:
- Locate your Python folder and go to
PythonPython38Libsite-packages - From there delete the Pyinstaller module and Pyinstaller dis.info folder
- Reinstall Pyinstaller using
pip install pyinstaller
Method 9
Goto – “C:UsersUsernameanaconda3Scripts” path and copy “pyinstaller.exe”
and paste it in the directory where you want to use pyinstaller, it worked for me
Method 10
- Open command
cmdfrom this path: ctrl+r, write “cmd” in box - Uninstall pyinstaller:
pip uninstall pyinstaller - Install it again:
pip install pyinstaller - Use the pyinstaller by writing
pyinstaller
Method 11
I found How we should fix this error :
C:Usersusername>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
Method 12
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.
Method 13
if you cannot do anything or you have less time, you can make the virtual environment and install pyinstaller there, then generate executable file
Method 14
Enter in Administrative Console: pip install pyinstaller
Method 15
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” AppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310Scripts
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
Method 16
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]AppDataLocalProgramsPythonPython39Scripts,
C:Users[username]AppDataLocalProgramsPythonPython39.
After that, you can run the command pyinstaller --onefile -w filename.py
Method 17
- Open PowerShell as adm
- Uninstall pyinstaller by running
pip uninstall pyinstaller - Type
yto confirm the uninstall - Reinstall using
py -m pip install pyinstaller
Method 18
If you don’t have pip in the PATH of your cmd, then you can run these commands in cmd for windows.
python -m pip install pyinstaller– for installing pyinstaller.python -m pip uninstall pyinstaller– for uninstalling pyinstaller.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0