1

I'm learning python and I'm attempting to make a python file executable. This is the code

#! /Users/<me>/PycharmProjects/untitled3
print ("Hello World")

in the terminal I typed.

$ chmod +x paperclip.py

And then

$ ./paperclip.py

But I get

-bash: ./paperclip.py: /Users/<me>/PycharmProjects/untitled3: bad interpreter: Permission denied

How do I fix this? Thanks.

Edit: Even after I changed the top line to

#!/Users/<me>/PycharmProjects/untitled3 python

or

#! /Users/<me>/PycharmProjects/untitled3 python3

Never mind. Thanks

  • the shebang is wrong. It should mention python. Can you try `#! /usr/bin/env python` instead? – Jean-François Fabre Oct 01 '16 at 21:55
  • 1
    `#! /usr/bin/env python3` would likely be more appropriate since you're wanting Python 3 instead of the default Python 2. You can create a symlink if it's not already done by following the steps in [this answer](http://apple.stackexchange.com/a/236394). –  Oct 01 '16 at 23:13
  • 1
    Use `#!/usr/bin/python` to use the OS X system python or a path to the *interpreter* you wish to use -- not the script path – dawg Oct 02 '16 at 02:17

0 Answers0