Virtualenv __future__ module works on command line, but not while running dev_appserver.py

。_饼干妹妹 提交于 2019-12-10 23:30:04

问题


I'm running into a strange error when running App Engine from within my virtualenv. Here is the error:

File "/home/matthew/dev/sdks/google_appengine_1.5.2/google/appengine/tools/dev_appserver.py", line 2318, in LoadModuleRestricted description)
File "/home/matthew/dev/projects/webapp2/project/src/webapp2.py", line 11, in <module>
  from __future__ import with_statement
ImportError: No module named __future__
  • If I run python in my virtualenv and type import __future__, it imports.
  • If I deactivate my virtualenv and run dev_appserver.py, the app works.
  • But if my virtualenv is active AND I run dev_appserver.py (even though #1 is true), the app does not work and I get the error above.

Why would __future__ be available while running the Python interpreter, but not dev_appserver.py?


回答1:


This is bug 4339. Make sure you use the SDK version 1.6.0, then do:

$ cd /usr/local/google_appengine/google/appengine/tools
$ wget "http://googleappengine.googlecode.com/issues/attachment?aid=43390029000&name=dev_appserver_import_hook.patch&token=974d9f138a5604dc7eb0526156b26cc7" -O dev_appserver.patch
$ patch -p1 < dev_appserver.patch


来源:https://stackoverflow.com/questions/6853710/virtualenv-future-module-works-on-command-line-but-not-while-running-dev-ap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!