close

How to use pyinstaller?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to use pyinstaller in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to use pyinstaller?

  1. How to use pyinstaller?

    Hello i made a code in python, i used it to turn itself into a exe.
    Make sure to have it in same directory as the file you want converted.

  2. use pyinstaller

    Hello i made a code in python, i used it to turn itself into a exe.
    Make sure to have it in same directory as the file you want converted.

Method 1

Try to write full path to pyinstaller (for example = C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts\pyinstaller.exe)

full cmd string must look like:

C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts\pyinstaller.exe --onefile myscript.py

Method 2

Hello i made a code in python, i used it to turn itself into a exe.

Make sure to have it in same directory as the file you want converted.

import subprocess
import shutil
import os

cmd = input("file name: ") # asks user for filename
extra = input("extra commands? eg -w -F if using two or more put a space between: ") # asks for extra options
suros = "pyinstaller "+ extra + " " + cmd + ".py" # sets run command
current_workin_path = os.getcwd() # gets current working path
dirt = current_workin_path + "/"+ cmd # set current working path for folder creation
os.mkdir(dirt) # creates folder for working path and for a copy
shutil.copy(cmd + ".py", current_workin_path + "/" + cmd + "/" + cmd + ".py") # creats copy of python file in the newly set path
os.chdir(current_workin_path + "/" + cmd + "/") # changes current working path to newly created one
subprocess.run(suros) # runs the command set eariler
os.remove(cmd + ".py") # delete the copy of python file

Hope this helps someone.

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read