shell调用python权限不足,使用Bash拒绝Python脚本的权限?

  • Post author:
  • Post category:python


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

terminal is showing following error “bash: ./filename.py: Permission denied”

what can I do for solve about problem?

解决方案

Do you have the appropriate incantation at the top of your python file? e.g.,

#!/usr/bin/python (or alternatively #!/usr/bin/env python)

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’