-1

I was trying to convert my main.py to a exe file

I followed a tutorial on youtube i did it like it said

first open cmd in the folder enter image description here

then type in pip install pyinstaller enter image description here then type in like this pyinstaller --onefile main.py but it does'nt convert it shows this enter image description here

  • 4
    Welcome to Stack Overflow. [Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. Instead, paste the code as text directly into your question. If you select it and click the `{}` button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code. – ChrisGPT was on strike Feb 07 '22 at 16:18
  • 1
    this question is already answered [here](https://stackoverflow.com/questions/45951964/pyinstaller-is-not-recognized-as-internal-or-external-command) take a look – PsyQuake Feb 07 '22 at 16:26

2 Answers2

0

This issue is probably caused because pyinstaller is not in the PATH environment variable.

First, find the full path of pyinstaller.exe - it should be in the Scripts directory of your Python installation (probably C:\Users\[USERNAME]\AppData\Local\Programs\Python\[Python_VER]\Scripts). Copy the full path.

Then open a command prompt (as Administrator) and run the command:

setx PATH "%PATH%;PYINSTALLER_PATH"

where PYINSTALLER_PATH is the full path of pyinstaller you have copied.

Then re-launch command prompt and run the command again.

0

While Eyal's solution is correct, there is an easier option. Just run this:

py -m PyInstaller --onefile main.py

It could also be python -m PyInstaller --onefile main.py depending on your system configuration.

Seth
  • 2,214
  • 1
  • 7
  • 21