I want to convert .py files to .exe files so I can execute them on a webpage. However. every method of doing this involves pyinstaller which I do not know how to install. Could someone either explain the procedure to get pyinstaller OR tell me if there are any other methods to convert .py to .exe without using pyinstaller
-
[how to install pyinstaller](https://pyinstaller.readthedocs.io/en/stable/installation.html) – sahasrara62 Jan 06 '21 at 14:14
1 Answers
Installing Pyinstaller
Installing pyinstaller is pretty simple and straight forward. All you gotta do is pip install pyinstaller
or python -m pip install pyinstaller
(obviously you have to make sure that your python and pip are in PATH
).To check if pyinstaller got installed correctly, simply type pyinstaller
in your cmd, if no errors appear, it means, you have pyinstaller installed. If for some reason, pyinstaller installs correctly but still doesn't work, you might want to add it in your PATH
. You can consider adding C:\Users\user_name\AppData\Roaming\Python\Python37\Scripts
to the Path
.
Using Pyinstaller
To convert the .py
file into a .exe
file, you can run the following commands (Make sure you are in the same directory as your python file) -
pyinstaller file_name.py
- Simply converts your python file into an executable. This will create a few folders and files, and when you will run your .exe
file, it will open up console and run your script.
pyinstaller -w file_name.py
- By adding a -w
, console will no longer appear while running your .exe
.
pyinstaller -F file_name.py
- By adding a -F
, only one folder will be created, which will be containing your .exe
and no other files.
pyinstaller -i icon.ico filename.py
- By adding a -i
, you will be able to add a .ico
file as your icon.
And of course you can use flags in combination to achieve even better results.
[External Links]
Using pyinstaller - https://pyinstaller.readthedocs.io/en/stable/usage.html#options
Installing pyinstaller - https://pyinstaller.readthedocs.io/en/stable/installation.html#installing-in-windows
Working of pyinstaller - https://pyinstaller.readthedocs.io/en/stable/operating-mode.html

- 304
- 2
- 6
-
Thank you very much!! I have one issue, I have just installed pip onto my desktop but it is not in PATH and I don't know how to change it so it is in PATH. Any tips? – Lucia Jan 06 '21 at 15:53
-
1To add pip to your path, just search for `pip.exe` and open its file location, and copy the path. Now open "Environment Variables" and add the copied path to it. I will post a link below this comment which will take you to a more detailed solution – ProgrammingEnthusiast Jan 06 '21 at 15:57
-
https://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command?page=1&tab=votes#tab-top – ProgrammingEnthusiast Jan 06 '21 at 16:00