1

I have written a project in PyCharm consisting of a .py file, a .txt file, a .ico file and the regular .idea folder for PyCharm projects. All is saved in C:\Users\user\PycharmProjects\myproject.

I would like to create a single-file .exe using PyInstaller. But when I run the command pyinstaller.exe --onefile --windowed myprogram.py, I get the following error:

'pyinstaller.exe' is not recognized as an internal or external command, operable program or batch file.

To my understanding, this is because "pyinstaller.exe" is not in the location in which I ran the command prompt.

However, if I run cmd in the pyinstaller folder (C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts), my project isn't there. So that doesn't work either.

What do I need to do to get my program into one .exe file?

fmw42
  • 46,825
  • 10
  • 62
  • 80
Peter
  • 21
  • 1
  • 1
  • 7
  • 2
    Possible duplicate of [Configuring Pycharm to run Pyinstaller](https://stackoverflow.com/questions/33906539/configuring-pycharm-to-run-pyinstaller) – Stevoisiak Apr 09 '18 at 18:58

2 Answers2

2

You can specify either file as absolute path:

C:\Users\pemho\AppData\Local\Programs\Python\Python35-32\Scripts\pyinstaller.exe --onefile --windowed myprogram.py should work from the project folder, as well as pyinstaller.exe --onefile --windowed C:\Users\user\PycharmProjects\myproject\myprogram.py from the pyinstaller folder.

Alternatively, you can add C:\Users\pemho\AppData\Local\Programs\Python\Python35-32\Scripts to your system PATH (see here).

jojonas
  • 1,634
  • 14
  • 24
1

Run pyinstaller from your project directory, but call it as the full directory to the .exe like C:\PathTo\Pyinstaller.exe

so your cmd would look something like

C:\Users\user\PycharmProjects\myproject> C:\PathTo\pyinstaller.exe --onefile --windowed myprogram.py