ImportError: cannot import name 'opentype' on new installation

Viewed 14569

I've just created a Google Cloud compute engine, installed google-cloud package with both pip and pip3, and I'm experiencing the following error when launching a script with 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'

On the compute engine the following packages are installed:

pyasn1==0.1.9
pyasn1-modules==0.2.1
google-cloud==0.30.0
google-cloud-bigquery==0.28.0

Which can be the problem here?

3 Answers

FWIW - Had the same issue - none of the above worked. I eventually discovered that if I did it under sudo it did work.

stracing the original - I found that I had a ~/.local directory which had a pyasn1 directory where it was trying to get the files from, but the opentype.py one did not appear there. When I deleted that whole directory - it started working.

I assume it was some sort of cache that was partial, and out-of-date???

Related