I am pulling my hair out trying to figure this out because I had it working until last week and somehow it broke.
When I setup a virtualenv for a Google App Engine app
Google AppEngine SDK makes a lot of trick in order to pull its install into sys.path, and these tricks rely on actual file's path. I think there might be a lot of various reasons why it fails. SDK doesn't install itself as a real python package, virtualenv doesn't do complete sandboxing, it just sets up an environment (obviously) and changes sys.path. And GAE SDK does this too, they both intefere, SDK is being developing rapidly and changing often, so this is extremely bumpy road to go.
Probably, it would be better if you'd explain what are you trying to achieve. My guess is that you're trying to create a clean environment to ensure that no 3rd-party module is available to application. If this guess is correct, I'd go with installing GAE SDK into virtualenv via requirements files as described here.
Same answer as bozzo. Here's instructions:
This is described in Issue 4339 for GAE. Here's how to fix it:
It's an issue 4339 with the GAE SDK, it's confirmed and there are two slightly different patches available in the bug entry that make it work.
What happens is dev_appserver.py
sets up a restricted python environment by disallowing access to any non-system-python modules and it does that by calculating the system python folder from the location of the os
module. In a virtualenv instance the os.py
gets symlinked into the virtualenv but gets compiled straight into virtualenv, and this is the path that dev_appserver uses, effectively blocking access to any module from the system python library that is not linked by virtualend, which is most of them. The solution is to "bless" both paths.
I think, since you've setup virtualenv with the --no-site-packages option, you need to install the SDK into the environment. --no-site-packages seperates the dev environment you're configuring from any other Python installation on your computer so, as you seem to have it configured you're calling a module that doesn't exist (in the environment) which is why it works with the env deactivated (which is then running Python from the default OS installation). Try setting up the dev env without the --no-site-packages option if you want to be able to access modules outside of the env.
I'm a little late to the conversation, but I was just having the same issue and I stumbled across gae_installer, which you can install in the usual way with pip install gae_installer
. This will put the google app engine (gae) sdk directly into your python path. Hope others find this useful.