brain storm
brain storm

Reputation: 31262

setting shebang for python scripts with python path

I have a script for which I am trying to set up shebang so that I execute ./script.py instead of python script.py. This works for me when it is the topmost line of my script

#!/usr/bin/env python. This uses env.

when I tried to do change this, #/usr/local/lib/python2.7, I get this error message

/usr/local/lib/python2.7: bad interpreter: Permission denied

when I checked my python version, it is

>>> import sys
>>> sys.version
'2.7.3 (default, Jun 21 2013, 13:45:37) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]'
>>> 

and sys.path gives /usr/local/lib/python2.7/*. Although I do not see anything specific for python2.7.3.

can you guide me as how to set up using pythonpath instead of env.

Thanks

Upvotes: 3

Views: 6063

Answers (2)

ksimons
ksimons

Reputation: 3826

The shebang line should contain the actual python interpreter executable, not just a path to your python install. Probably can find the one you're looking for with which python

Upvotes: 5

Wayne Werner
Wayne Werner

Reputation: 51877

which python on your command line should give you the path to the shebang line you need.

Upvotes: 3

Related Questions