Python:编译成Unix命令行应用 [英] Python: compile into an Unix commandline app

查看:69
本文介绍了Python:编译成Unix命令行应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定是否搜索了错误的词,但是在这个主题上我找不到很多。我使用的是osx,我想将命令行python脚本编译成一个小的命令行应用程序,然后将其放入usr / local / bin中,以便可以从任何地方调用它。

I am not sure if I searched for the wrong terms, but I could not find much on this subject. I am on osx and I'd like to compile a commandline python script into a small commandline app, that I can put into usr/local/bin so I can call it from anywhere. Is there a straighforward way to do that?

谢谢

推荐答案

最简单的方法是将文件从 filename.py 重命名为 filename 并将此行添加到顶部

The simplest way to do this is to rename your file from filename.py to filename and add this line to the top of the file.

#!/ usr / bin / env python

您可能还需要在文件上设置可执行位,可以在命令行上使用 chmod + x 来设置。

You may also need to set the executable bit on the file, which may be set using chmod +x on the command line.

这篇关于Python:编译成Unix命令行应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆