0

When trying to find a good way to "bundle" my python file into an .exe, I came across pyinstaller. I looked up a guide on how to use it and found this guide. I simply installed pyinstaller using pip install pyinstaller and it seemed to install fine but when trying to use pyinstaller in the console it raised an error saying that 'pyinstaller' is not recognized as an internal or external command, operable program or batch file. I even tried changing the directory to where my file was located but it still raised the same error. When trying to install it again via pip (in case some error occured) I got this message:

Requirement already satisfied: pyinstaller in c:\users\[me]\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (4.1)
Requirement already satisfied: pefile>=2017.8.1; sys_platform == "win32" in c:\users\[me]\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pyinstaller) (2019.4.18)
Requirement already satisfied: altgraph in c:\users\[me]\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pyinstaller) (0.17)
Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in c:\users\[me]\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pyinstaller) (2020.10)
Requirement already satisfied: setuptools in c:\program files\windowsapps\pythonsoftwarefoundation.python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\lib\site-packages (from pyinstaller) (49.2.1)
Requirement already satisfied: pywin32-ctypes>=0.2.0; sys_platform == "win32" in c:\users\w[me]\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: future in c:\users\[me]\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pefile>=2017.8.1; sys_platform == "win32"->pyinstaller) (0.18.2)

2 Answers2

0

You can execute pyinstaller by prefixing python3

python3 -m pyinstaller file.py

else without prefix you should follow below method,

In Windows, pyinstaller executable which is located at

C:\Users\USER_NAME\AppData\Roaming\Python\Python37\Scripts
                             (or)
C:\Program Files\Python37\Scripts

and copy the pyinstaller executable path and add it to Windows System Environment Variables.This can be done by

  1. Click on Search in start menu and search for Edit System Environment Variables.

  2. Click on Environment variables at bottom. Click on Path and click edit.

  3. Click on New and add the copied pyinstaller executable path in the path section and click OK.

  4. Now check pyinstaller in CMD.

Happy Coding :)

Srikeshram
  • 87
  • 1
  • 5
0

Try Prefixing The Command pyinstaller With python -m:

python -m PyInstaller yourscript.py

If That Didn't Work, Try With python3 -m Or py -m:

python3 -m PyInstaller yourscript.py
py -m PyInstaller yourscript.py
Dev-I-J
  • 49
  • 1
  • 8