Python3 shebang -bash: ./main.py: Permission denied

64 Views Asked by At

Please actually read my post instead of just the title. This is a larger system issue, not a typo or a file permissions issue.

I am attempting to run my script without having to type in 'python3' before every test run, and potentially to make scheduling a cron job easier. No matter what I've tried, I always get the error -bash: ./main.py: Permission denied. I've tried the following:

  • Using every version of python in /usr/bin/ with or without a space after '#!'
  • Using every version of python with /usr/bin/env [python version].
  • Running chmod 777 on every python file in /usr/bin
  • Running chmod 777 on every file and folder in my script directory.
  • The user running the script is in both the root and wheel groups.
  • Running the script as root gives the same results.
  • Adding the shebang to every python file in my script directory.

I'm at a loss here. Every other post I've seen about this is just saying to do chmod +x, which doesn't apply in my case.

Edit 1: I've now tried reinstalling both bash and python, as well as running dos2unix on all of my script files to make sure the EOL characters weren't the problem. No luck.

1

There are 1 best solutions below

0
Binsky734 On

The problem ended up being that the directory the scripts were in had the noexec flag set.