Question

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.

Was it helpful?

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top