简体   繁体   中英

How to convert Python 3 script to executable file in Mac Catalina

I really need an updated answer for this question. I want to convert the script into an executable that runs when I'd double click it. Some procedures, available online since last two-three years, are not working. I have just one script that's utilizing selenium and Geckodriver. The response I get against "which python3" is在此处输入图片说明

So kindly give answer if you've had yourself performed such a task in last few months.

您可以使用在 Mac 上运行的 PyInstaller 来生成可执行文件。

PyInstaller didn't work in my case. Maybe it'd work on someone else's system. So, I went the simple "chmod" way and converted the python file into an executable. These were the steps:

  1. On Terminal, I ran which python3 and copy-pasted the result at the start of my python script, preceded with #!
  2. Then I changed the extension of my python file to .command
  3. On Terminal, I ran the command chmod +x fileName.command (755 instead of +x works too)

So, this is how I made my python file executable. There are other solutions too, but this one worked for me and is also simpler.

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