python - 谷歌应用引擎 'No module named pwd'

标签 python google-app-engine flask

我能够很好地运行我的 Google App Engine 项目(我正在使用 Python Flask 开发网络应用程序),但是当我将系统从 Ubuntu 12.04 升级到 14.04 时。 App Engine 项目在本地系统上变得无响应,但它在生产环境中运行良好。我还保持我的项目更新,将我的源代码放在 github 上,所以我删除了所有内容并再次从我的 github 帐户克隆了一个新的存储库。但是当我运行这个项目时,它给了我以下错误,如果之前有人遇到过这个错误,请帮助我。

我使用这个命令来运行我的项目

$ dev_appserver.py src/

并在终端输出这个错误

WARNING  2015-02-23 06:13:02,341 simple_search_stub.py:1115] Could not read search indexes from /tmp/appengine.practical-now-720.chitrank/search_indexes
INFO     2015-02-23 06:13:02,347 api_server.py:172] Starting API server at: http://localhost:60268
INFO     2015-02-23 06:13:02,368 dispatcher.py:186] Starting module "default" running at: http://localhost:8080
INFO     2015-02-23 06:13:02,369 admin_server.py:118] Starting admin server at: http://localhost:8000
ERROR    2015-02-23 06:13:05,655 wsgi.py:263] 
Traceback (most recent call last):
  File "/home/chitrank/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/chitrank/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/home/chitrank/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/chitrank/Documents/Google_App_Engine/GoogleCloudPlatform/uscore-firstsubmit/uscore/src/run.py", line 5, in <module>
    import application
  File "/home/chitrank/Documents/Google_App_Engine/GoogleCloudPlatform/uscore-firstsubmit/uscore/src/application/__init__.py", line 47, in <module>
    import urls
  File "/home/chitrank/Documents/Google_App_Engine/GoogleCloudPlatform/uscore-firstsubmit/uscore/src/application/urls.py", line 10, in <module>
    from application import views
  File "/home/chitrank/Documents/Google_App_Engine/GoogleCloudPlatform/uscore-firstsubmit/uscore/src/application/views.py", line 49, in <module>
    import requests
  File "/home/chitrank/Documents/Google_App_Engine/GoogleCloudPlatform/uscore-firstsubmit/uscore/src/lib/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/home/chitrank/Documents/Google_App_Engine/GoogleCloudPlatform/uscore-firstsubmit/uscore/src/lib/requests/utils.py", line 19, in <module>
    from netrc import netrc, NetrcParseError
  File "/usr/lib/python2.7/netrc.py", line 7, in <module>
    import pwd
  File "/home/chitrank/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 898, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named pwd
INFO     2015-02-23 06:13:05,710 module.py:718] default: "GET /_ah/warmup HTTP/1.1" 500 -

如果有人解决了这个问题,请帮我解决以下问题。

最佳答案

google_appengine/google/appengine/tools/devappserver2/python/sandbox.py 中有 _WHITE_LIST_C_MODULES 列表,并添加 'pwd'它对我有用。

Google 实际上是在沙盒中运行。由于在生产环境中没有问题,较旧的 GAE SDK 将支持 pwd 导入,但他们即将删除它。

关于python - 谷歌应用引擎 'No module named pwd',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28668007/

相关文章:

python - 将列从一个数据框映射到另一个数据框以创建新列

python - 在 RESTful Web 服务中,服务器需要很长时间才能响应是否可以接受?

python - PyMongo 和 Flask-PyMongo 库之间的区别

python - NLTK:矢量化后的特征缩减

python - matplotlib 在 while 循环中更新绘图,以日期为 x 轴

google-app-engine - GAE 搜索 API - 对 Twitter 风格的扇出有用吗?

python - 本地主机上的 Google App Engine GQL 查询

python - 使用 django 过滤应用程序引擎创建的引用模型的下拉列表

mysql - 'NoneType' 对象没有属性 'cursor'

python - 亚马逊 EC2 虚拟环境 : pip says it installed numpy but python can't find it