GoogleAppEngine and latest Python2.7: location of "google" directory

The latest Python2.7 has a directory google

in dist-packages

, making it impossible to import a directory google

that contains appengine

other packages from elsewhere. Such a directory should work for import from GoogleAppEngine (GAE) code to dev_server. Otherwise, such an import will fail. An example of such an import:

from google.appengine.api import mail

what gives

ImportError: No module named appengine.api

This problem is similar to the one in here and indeed after Alex Martelli's answer the location of my google


In [1]: import google
In [2]: google.__file__
Out[2]: '/usr/lib/python2.7/dist-packages/google/__init__.pyc'


not the one where I placed the unpacked GAE files.

Any recommended way to fix this? I've already thought of dirty hacks to fix this, like putting soft links in google's dist-packages directory, but again, this one is dirty.


source to share

2 answers

Packages have a special attribute __path__

that tells the Python interpreter where to look for modules and subpackages. By modifying this, you can let Python find content from both directories google

. Using the pkgutil module this should work (untested):

import pkgutil
import google
google.__path__ = pkgutil.extend_path(google.__path__, google.__name__)




Are you sure this google directory comes with Python 2.7? I saw this too, but it first came up when I installed some utility from Google (Google Storage for Developers I think). I also think there is a .pth file associated with this.



All Articles