How do you make a Python executable file on Mac? [closed]

霸气de小男生 提交于 2019-12-23 07:57:58

问题


My google searching has failed me. I'd like to know how to make an executable Python file on OS X, that is, how to go about making an .exe file that can launch a Python script with a double click (not from the shell). For that matter I'd assume the solution for this would be similar between different scripting languages, is this the case?


回答1:


To make a script file (such as Python) executable from a shell, you need to include so called hash-bang line as the first line of the file (adjust to your location of python binary):

#!/usr/local/bin/python

Then you also need to make the file executable by setting the execute bit by running e.g. chmod u+x <name_of_the_script.file>.

After these steps you can run the program directly from Terminal.

./<name_of_the_script.file>



回答2:


You can run python scripts through OS X Terminal. You just have to write a python script with an editor, open your Terminal and enter python path_to_my_script/my_script.py



来源:https://stackoverflow.com/questions/29584270/how-do-you-make-a-python-executable-file-on-mac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!