Python子模块导入错误(Google App Engine dev_appserver.py)

时间:2018-04-17 11:16:48

标签: python google-app-engine import virtualenv dev-appserver

我在appengine_config.py中有以下代码:

...
import six
print six.__version__
print six.moves
import six.moves

输出如下:

1.11.0
<module 'six.moves' (built-in)>
ERROR    2018-04-17 10:51:19,875 wsgi.py:263] 
Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 351, in __get
attr__
    self._update_configs()
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 287, in _update_configs
    self._registry.initialize()
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 160, in initi
alize
    import_func(self._modname)
  File "/home/user/project/appengine_config.py", line 17, in <module>
    from six.moves import http_client
ImportError: No module named moves

moves在通过six访问时是如何成为模块的,但是无法自行导入?

提供有关环境的背景信息:

  • 我使用干净的Debian GCE VM。

  • 从virtualenv中安装python 2.7,virtualenv,安装一个基本依赖项的简短列表。

  • 该脚本从dev_appserver.py(Google App Engine标准环境本地开发服务器)
  • 中运行
  • six.moves从python shell
  • 导入正常

1 个答案:

答案 0 :(得分:0)

您已导入six。这包括six.moves。所以只需将其用作six.moves即可。要导入只是移动,请使用:

from six import moves