Saturday, April 30, 2011

importing gaeutilities or any other module by dev_appserver

I'm developing a gae application on a windows machine. to have session handling I downloaded gaeutilities and added its path (C:\Python25\Lib\site-packages\gaeutilities-1.2.1) to the registry ("PythonPath" item under python25).

in my code this is how I import the gaeutilities Session class:

from appengine_utilities.sessions import Session

when gae engine (dev_appserver.py) tries to import it, an exception is raised, stating an importerror and "no module named appengine_utilities.sessions"

on the other hand, pyscripter can find the module (autocomplete becomes available for the Session class), and I can import the module within the python interpreter (the same one that dev_appserver uses, python 2.5.4).

for a remedy, I created a PYTHONPATH environmental variable and also added the path to it. nothing changes.

I'm lost. what am I doing wrong?

important edit: I have found myself to be totally unable to import any 3rd party gae modules. PYTHONPATH is correct, sys.path is correct, registry is correct, still dev_appserver complains of importerror.

From stackoverflow
  • Strange.

    I would start troubleshooting by making 100% sure that the sys.path that dev_appserver.py uses does include C:\Python25\Lib\site-packages\gaeutilities-1.2.1.

    I suggest you display sys.path in a HTML view served by dev_appserver.py.

    Check permissions on gaeutilities-1.2.1 directory and subdirectories. Perhaps the python interpreter is unable to create *.pyc files or something like that.

    Another suggestion:

    Put the appengines_utilities folder in your application directory (the directory that contains your app.yaml file). I guess you need all third-party stuff there anyway if you want to upload the code to google's servers.

    shanyu : Thank you, I followed your suggestions to see that sys.path includes the folder and no permission restrictions on the folders. Any other suggestions? :)
    codeape : I updated my answer with another suggestion.
    shanyu : That does it, thanks.

0 comments:

Post a Comment