问题
I use python 3.6.0.
I want to play with the Google Drive API.
When I import oauth2client.service_account
I get this error :
Traceback (most recent call last):
File "test.py", line 3, in <module>
from oauth2client.service_account import _ServiceAccountCredentials
File "C:\Users\aaron\Anaconda3\lib\site-packages\oauth2client\service_account.py", line 26, in <module>
from oauth2client import crypt
File "C:\Users\aaron\Anaconda3\lib\site-packages\oauth2client\crypt.py", line 23, in <module>
from oauth2client import _pure_python_crypt
File "C:\Users\aaron\Anaconda3\lib\site-packages\oauth2client\_pure_python_crypt.py", line 24, in <module>
from pyasn1_modules.rfc2459 import Certificate
File "C:\Users\aaron\Anaconda3\lib\site-packages\pyasn1_modules\rfc2459.py", line 20, in <module>
from pyasn1.type import opentype
ImportError: cannot import name 'opentype'
回答1:
Consider upgrading your google-auth module
pip install --upgrade google-auth-oauthlib
and also the pyasn1_module, which is reponsible for implementation of ASN.1 types and codecs as a Python package
pip install --upgrade pyasn1-modules
UPDATE Working solution: Force install your modules
pip install -U -I pyasn1 pyasn1-modules
来源:https://stackoverflow.com/questions/52163971/from-oauth2client-service-account-import-serviceaccountcredentials-cannot-impo