![](/img/trans.png)
[英]from six.moves import urllib ImportError: No module named six.moves
[英]Google API Python Client: "from six.moves import zip ImportError: No module named moves"
我正在尝试使用 googleapiclient 在我的 Python 2.7 代码中使用 Google Sheets API,但我收到以下错误:“from Six.moves import zip ImportError: No module named move ”。
我在 Mac 上使用 Python 2.7.10。
我的程序是使用 Webapp2 构建的,部署在 Google AppEngine 上并连接到 Google Datastore。
我正在使用谷歌使用第三方库的最佳实践,使用requirements.txt
、 lib/
和appengine_config.py
,描述如下: https : //cloud.google.com/appengine/docs/standard/python/tools/using-libraries -python-27#installing_a_third-party_library
我曾尝试在app.yaml
中将六个作为捆绑库列出
我尝试过使用不同版本的six
和google-api-python-client
我已经尝试过这里建议的解决方案:
2) Google App Engine: from Six.moves import http_client no module namedmoves
注意事项:
我可以从我的 Python shell 成功调用 Google Sheets API。
我尝试了一种不同的、更笨拙的方法; 从https://code.google.com/archive/p/google-api-python-client/downloads下载google-api-client-gae-1.2.zip
并将其解压缩到我的根目录中。 这需要将apiclient
导入到我的代码中,而不是googleapiclient
,虽然导入 6.moves 没有任何问题,但它抛出了缺少 API 密钥的错误。 我相信如果我解决了上面的 Six.moves 导入错误,这些错误就不会成为问题,因为我有一个GOOGLE_APPLICATION_CREDENTIALS
环境变量集, google_api_python_client
会接收到它。
我的代码:
from googleapiclient import discovery
class SpreadsheetProcessor:
def __init__(self, spreadsheet_id, range_):
service = discovery.build('sheets', 'v4')
request = service.spreadsheets().values().get(
spreadsheetId=spreadsheet_id, range=range_)
response = request.execute()
self.results = [value[0] for value in response['values']]
我的点子冻结:
autopep8==1.4.3
cachetools==3.0.0
certifi==2018.11.29
chardet==3.0.4
enum34==1.1.6
fancycompleter==0.8
futures==3.2.0
google-api-core==1.7.0
google-api-python-client==1.7.7
google-auth==1.6.2
google-auth-httplib2==0.0.3
google-cloud-core==0.29.1
google-cloud-datastore==1.7.3
googleapis-common-protos==1.5.6
grpcio==1.18.0
httplib2==0.12.0
idna==2.8
linecache2==1.0.0
pdbpp==0.9.3
protobuf==3.6.1
pyasn1==0.4.5
pyasn1-modules==0.2.3
pycodestyle==2.4.0
Pygments==2.3.1
pyrepl==0.8.4
pytz==2018.9
requests==2.21.0
rsa==4.0
six==1.12.0
traceback2==1.4.0
uritemplate==3.0.0
uritemplate.py==3.0.2
urllib3==1.24.1
wmctrl==0.3
我的完整堆栈跟踪:
ERROR 2019-01-20 11:52:23,705 wsgi.py:263]
Traceback (most recent call last):
File "/Users/muzzialdean/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/muzzialdean/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Users/muzzialdean/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/muzzialdean/Muzzi/tech-tests/ghostr/ghostr.py", line 3, in <module>
from models import Ghost, GhostDatabase
File "/Users/muzzialdean/Muzzi/tech-tests/ghostr/models.py", line 2, in <module>
from googleapiclient import discovery
File "/Users/muzzialdean/Muzzi/tech-tests/ghostr/lib/googleapiclient/discovery.py", line 21, in <module>
from six.moves import zip
ImportError: No module named moves
INFO 2019-01-20 11:52:23,715 module.py:861] default: "GET / HTTP/1.1" 500 -
six
模块是 App Engine Python 2.7 运行时中的内置第三方库之一。 唯一可用的版本是1.9.0
,但这个版本有six.moves
子模块:
$ python
Python 2.7.14 (default, Sep 13 2018, 17:12:41)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves import zip
>>> import six
>>> six.__version__
'1.9.0'
看起来您的lib
目录中可能有一个旧版本的six
,或者您的项目中可能有一个名为six.py
的文件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.