First I ran:
chmod +x hello.py
./hello.py
and got:
Permission denied
I thought the 755 bit was enough, but the real issue was the shebang line.
If the first line of a script doesn't point to a valid interpreter, the kernel tries to execute the file directly and fails with permission denied.
The fix? Add a proper shebang:
!/usr/bin/env python3
or point to the exact path:
!/usr/bin/python3
Then run chmod +x hello.py again.
Now it works.
Lesson: Always double-check the shebang, especially when moving scripts between machines.
Have you run into this before?
Top comments (0)