amri123 amri123
amri123 amri123

Reputation: 23

How to make a .exe from python script with pyinstaller?

I'm trying to package up my python file into an .exe file using pyinstaller.

I managed to install pyinstaller with pip but when trying to use pipinstaller in a command window it wouldn't work. I found online to use python -m PyInstaller instead which then worked. But after using cd to change the directory and then doing python -m PyInstaller filename.py it would always give a list of errors saying 1920, 'LoadLibraryExW', 'The file cannot be accessed by the system.'.

I'm using windows 10, python 3.8.3 and the newest version of pip but I couldn't find a soloution. I ran command prompt as an operator but it still wouldn't help.

Any soloutions?

Upvotes: 2

Views: 17702

Answers (3)

amri123 amri123
amri123 amri123

Reputation: 23

I decided to try another one after failing to use pyinstaller. I used py2exe and shortly after trying managed to convert it into an .exe file along with moving my files inside of where my python was stored.

Upvotes: 0

Peyman Majidi
Peyman Majidi

Reputation: 1985

Go to the path you've installed your python

if you don't know where you installed python, in the console type 'where python'

> where python
C:\Users\{username}\AppData\Local\Programs\Python\Python38\python.exe

then go to the path

next, go to 'Scripts' folder

cd Scripts

in the Scripts folder, make sure there is pyinstaller.exe file there

if you find pyinstaller.exe in this folder, you are sure pyinstaller is installed on your system, then

> pyinstaller {path to the main.py}

there is two useful switch for pyinstaller

  1. --onefile >> your project packaged into ONE file
  2. --noconsole >> no console appear when your app is running

For eg:

pyinstaller d:\myapp\main.py --onefile

You can find your final dot.exe file in the 'dist' folder in 'Scripts' folder

example

Upvotes: 4

DarkTemplar008
DarkTemplar008

Reputation: 1

I encounter the same question, so I uninstall python which is installed from windows appstore, and reinstall it from the website, and it works fine now, hope it help

Upvotes: 0

Related Questions