使用Bash对Python脚本的权限被拒绝了吗? [英] Permission denied for Python script using Bash?
问题描述
我是Ubuntu的新手...我正在尝试运行我的第一个简单的python程序"Hello World" ... 在终端中运行以下命令后
I am new to Ubuntu... I am trying to run my first simple python program "Hello World" ... After running following commands in terminal
1. chmod +x filename.py
2. ./filename.py
终端显示以下错误"bash: ./filename.py: Permission denied
"
我该如何解决问题?
terminal is showing following error "bash: ./filename.py: Permission denied
"
what can I do for solve about problem?
推荐答案
在python文件的顶部是否有适当的咒语?例如,
Do you have the appropriate incantation at the top of your python file? e.g.,
#!/usr/bin/python
(或#!/usr/bin/env python
)
只需澄清一下,chmod +x
仅使文件可执行,它不运行.
Just to clarify, chmod +x
only makes a file executable, it doesn't run it.
我假设您的脚本看起来没有比这更复杂的了:
And I'm assuming your script looks like nothing more complex than this:
#!/usr/bin/env python
print 'hello world'
这篇关于使用Bash对Python脚本的权限被拒绝了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!