views:

229

answers:

2

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.

+1  A: 

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".

Nick Johnson
A: 

When doing

$ python2.5 dev_appserver.py guestbook/

what you are passing to the executable python2.5 is CURRENT_PATH/dev_appserver.py.

You have to execute using

$ python /opt/google_appengine/dev_appserver.py guestbook/

or

$ dev_appserver.py guestbook/

if dev_appserver.py has a shebang for Python, that is, as Nick Johnson points out, #!/usr/bin/env python2.5 or #!/usr/bin/env python.

Unless you have a very good reason, don't over specify the python version, use the generic python command, that is a symlink to the latest version.

voyager
He does have a very good reason: The App Engine SDK currently only supports Python 2.5.
Nick Johnson
@Nick: point taken, but whenever I read something along the lines of *I'm new to Python so I would appreciate any help.*, I try and give them a few pointers to things they might pick up without a full understanding.
voyager
Fair enough. (Extra text to make SO happy)
Nick Johnson