Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

python - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...