[英]make .py file executable in ubuntu 15.04
I am running ubuntu 15.04. 我正在运行ubuntu 15.04。 I have a simple python programme test.py
我有一个简单的python程序test.py
#!/user/bin/python
print "hello, python"
I want to make test.py file executable. 我想使test.py文件可执行。 Currently when i try to run the file using ./test.py commant its showing
目前,当我尝试使用./test.py命令运行文件时,显示
bash: ./test.py: /user/bin/python: bad interpreter: No such file or directory bash:./test.py:/ user / bin / python:错误的解释器:没有这样的文件或目录
whereis python
python在哪里
command showing the following thing result 显示以下结果的命令
python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.4 /usr/bin/python3.4m /usr/lib/python2.7 /usr/lib/python3.4 /etc/python /etc/python2.7 /etc/python3.4 /usr/local/lib/python2.7 /usr/local/lib/python3.4 /usr/include/python2.7 /usr/include/python3.4m /usr/share/python /usr/share/man/man1/python.1.gz
python:/ usr / bin / python /usr/bin/python2.7 /usr/bin/python3.4 /usr/bin/python3.4m /usr/lib/python2.7 /usr/lib/python3.4 / etc / python /etc/python2.7 /etc/python3.4 /usr/local/lib/python2.7 /usr/local/lib/python3.4 /usr/include/python2.7 /usr/include/python3.4m / usr / share / python /usr/share/man/man1/python.1.gz
It should be #!/usr/bin/python
not user
它应该是
#!/usr/bin/python
不是user
To find the full path of your python interpreter, run this command which python
and it'll give you something like /usr/bin/python
. 要找到您的python解释器的完整路径,请运行以下命令
which python
,它将为您提供类似/usr/bin/python
。
Correct one is : 正确的是:
for python 2x 对于python 2x
#!/usr/bin/env python
^^^
usr not user
for python 3x 对于python 3x
#!/usr/bin/env python3
you also need to give your file executable permission 您还需要授予文件可执行权限
chmod u+x test.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.