EvilTosha
EvilTosha

Reputation: 167

Python submodule import error (Google App Engine dev_appserver.py)

I have the following code in appengine_config.py:

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

The output is as follows:

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

How is it possible that moves is a module when accessed through six, but can't be imported on its own?

To give some context about the environment:

Upvotes: 1

Views: 395

Answers (1)

GAEfan
GAEfan

Reputation: 11360

You've already imported six. That includes six.moves. So just use it as six.moves. To import just moves, use:

from six import moves

Upvotes: 0

Related Questions