Permission denied for Python script using Bash?

后端 未结 3 1365
野性不改
野性不改 2020-12-19 09:22

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         


        
3条回答
  •  生来不讨喜
    2020-12-19 09:51

    Some possibilities:

    1. What does it say if you type umask? chmod +x will only make a file executable for you if your umask doesn't block the user executable bit. A typical umask such as 0022 will not block the user execute bit, but a umask like 0122 can. (See the Description section of chmod(1) for more info.)

    2. To execute a script such as a Python script, you also need read permission. Try chmod u+rx filename.py and execute the script again.

    3. It's also remotely possible that whatever interpreter you've specified in the file with the "hashbang" line at the beginning of your file (e.g. #!/usr/bin/env python) isn't executable, although that in my experience yields a different error message.

提交回复
热议问题