Search code examples
pythongoogle-app-engineubuntu-9.10pythonpath

pythonpath issue? "python2.5: can't open file 'dev_appserver.py': [Errno 2] No such file or directory"


I added this line to my .bashrc (Ubuntu 9.10):

export PYTHONPATH=/opt/google_appengine/

And then I ran the dev_appserver through python2.5 on Ubuntu like this:

$ python2.5 dev_appserver.py guestbook/
python2.5: can't open file 'dev_appserver.py': [Errno 2] No such file or directory

As you can see, it can't find dev_appserver.py even though it's in my /opt/google_appengine/ directory. Just to make sure it's not a permissions issue I did this:

sudo chmod a+rwx dev_appserver.py

To check whether it's been added to the system path for python2.5 I did this:

$ python2.5
Python 2.5.5 (r255:77872, Apr 29 2010, 23:59:20) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for line in sys.path: print line
... 

/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg
/opt/google_appengine/demos
/opt/google_appengine
/usr/local/lib/python25.zip
...

The directory shows up in this list so I don't understand why it can't be found when I type:

$ python2.5 dev_appserver.py guestbook/

I'm new to Python so I would appreciate any help. Thanks.


Solution

  • Python doesn't observe PYTHONPATH when looking for a script you name on the command line. You either need to supply the complete path to dev_appserver.py, or modify the first line of dev_appserver.py (and other tools) to start with "#!/usr/bin/env python2.5".