ImportError:无法在新安装时导入名称'opentype'

use*_*546 8 python google-bigquery google-cloud-platform

我刚刚创建了一个谷歌云计算引擎,安装了带有pip和pip3的google-cloud软件包,我在使用python3启动脚本时遇到以下错误

    from google.cloud import bigquery
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/bigquery/__init__.py", line 35, 
in <module>
    from google.cloud.bigquery.client import Client
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/bigquery/client.py", line 36, in
 <module>

(more traceback lines..)

    from pyasn1_modules.rfc2459 import Certificate
  File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <modu
le>
    from pyasn1.type import opentype
ImportError: cannot import name 'opentype'
Run Code Online (Sandbox Code Playgroud)

在计算引擎上,安装了以下软件包:

pyasn1==0.1.9
pyasn1-modules==0.2.1
google-cloud==0.30.0
google-cloud-bigquery==0.28.0
Run Code Online (Sandbox Code Playgroud)

这可能是问题所在?

Cap*_*pet 39

发布我的解决方案,以防它帮助其他人 - 这为我解决了这个问题:

pip install --upgrade google-auth-oauthlib

这里讨论更多细节:https://www.raspberrypi.org/forums/viewtopic.php?f = 114&t = 198933&p = 1241439#p1241439


dse*_*sto 18

看起来你有pyasn1的问题,所以你可以尝试安装一个较新的版本(最新版本为0.4.2),甚至可以手动重新安装:

sudo apt-get --reinstall install python-pyasn1 python-pyasn1-modules
Run Code Online (Sandbox Code Playgroud)

如果你在virtualenv中,请使用:

pip install pyasn1 pyasn1-modules
Run Code Online (Sandbox Code Playgroud)

  • @ Yandrak3谢谢你 - 我最终发现我需要的是'pip install --upgrade google-auth-oauthlib`. (5认同)