简体   繁体   中英

Running a Python script by double-clicking desktop icon on Mac OS

I am very new to programming. I am trying to create a desktop icon that, when clicked on, will run my Python script on Mac OS.

The first line of my code involves input from the user. How can I create a desktop icon of my Python script, that when clicked, allows the user to enter the input in order to cause the Python script to start?

I have tried Pyinstaller; however, when I enter:

pyinstaller "myprogram".py

into the Mac terminal, I receive a "dist" file that includes Python script with an ".exe" file extension. However, when I click on this extension, I receive this response in the terminal window:

logout
Saving session...
...copying shared history...
...saving history...truncating history 
files...
...completed.

I would like the Python script to run in order to have a user type their input in order to have the program run. Any help would be greatly appreciated.

Pyinstaller detects the OS and the version you make is only compatible with the system you build it on, they mention that on their page, so it shouldn't be building an.exe; whenever I use pyinstaller on my mac the dist has a.app and a unix executable, you don't have both of those files in there?

also, I just notices your syntax, you should not have the filename in quotations try:

pyinstaller --clean --windowed --onefile yourapp.py

in your terminal from the directory that has your app. First delete the old folders and.spec it created the first time as well.

Also, I just went through a bundle of issues in a similar vein. If the problem persists after you delete and rerun pyinstaller with proper syntax, check out this page, I have a rather large answer all the way at the bottom, and there are other angles on the same issue there as well.

https://github.com/pyinstaller/pyinstaller/issues/3820

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM