How to use pyinstaller?

2019-03-14 01:48发布

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?

2条回答
该账号已被封号
2楼-- · 2019-03-14 02:04

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.

查看更多
小情绪 Triste *
3楼-- · 2019-03-14 02:12

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
查看更多
登录 后发表回答