Reputation: 21
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?
Upvotes: 1
Views: 19066
Reputation: 1675
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).
Upvotes: 2
Reputation: 31
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
Upvotes: 1