Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pyinstaller?

Okay so I'm a complete noob in programming and I'm trying to compile a simple program I wrote that takes in a string and prints out the string in morse code it's called morse.py. I installed pyinstaller using

 pip install pyinstaller

and I am trying to compile my program using pyinstaller.

Now I've searched a bit and it says that I need to write pyinstaller morse.py, but I don't really know where to write that. I tried moving to the directory of my program and doing that in CMD but it didn't work. I tried making a python program in the same directory and doing that and that also didn't work. I couldn't find anything very helpful to tell me exactly how to compile the file.

Can someone please help?

like image 937
user3333708 Avatar asked Dec 24 '15 13:12

user3333708


People also ask

Do you need Python to run a PyInstaller exe?

To your users, the app is self-contained. They do not need to install any particular version of Python or any modules. They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python.

How do I configure PyInstaller?

To install PyInstaller: Go to your command prompt (Start -> Run -> cmd) type the following command cd c:\python27\scripts press enter, this should be where your pip.exe file is located. Once you are in this directory type pip install pyinstaller press enter.


1 Answers

I would suggest to first read the Using Pyinstaller section in the documentation of the module itself.

You can also use some tutorials (e.g. Matt Borgerson's one).

In order to recap you should:

  • write your script and make sure that it works
  • run from the command line:

    ~\ pyinstaller your_file_name.py

  • this command will generate a your_file_name.spec file where you can include all the dll required by your application and any custom settings (Using Spec Files)

  • once you have decided what to include in your .exe application you can run from the command line

    ~\ pyinstaller [option1] [option2] your_file_name.py

You can find the full list the options in the documentation. An example could be pyinstaller.exe --onefile --windowed --icon=app.ico app.py where:

  • --onefile: Create a one-file bundled executable.
  • --windowed: Parameter to chooseif you are compiling in Mac OS X or Windows
  • --icon= : Choose the file to use as icon for file.

You can create your exe file very easily also with py2exe.

like image 175
mabe02 Avatar answered Oct 11 '22 04:10

mabe02