etingof/pyasn1

ImportError: cannot import name 'opentype'

Closed this issue ยท 14 comments

Since the last update of 4 hours ago my CI broke because a module is using your pyasn1 module.
I received the following in my stack trace:

  File "/usr/local/lib/python3.5/dist-packages/oauth2client/_pure_python_crypt.py", line 24, in <module>
    from pyasn1_modules.rfc2459 import Certificate
  File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <module>
    from pyasn1.type import opentype
ImportError: cannot import name 'opentype'

Is this anything related to the last changes made in this module and a way this is fixable on my side or with a new release of this module?

It must have something to do with the dependencies!

It feels like you are using pyasn1-modules 0.2.1 with pyasn1-0.3.x rather than pyasn1-0.4.1+ which is the official dependency. Can you check that?

Thanks!

Unfortunately I'm not using ASN myself. It must be in a module that I'm using. Right now I'm trying to figure out what module it is to see if I can do anything about it.

Thanks for the quick response by the way

May be just pip install --upgrade pyasn1-modules ?

Or send pip list here to confirm my suspicion. ;-)

Upgrading pyasn1-modules did the trick! Thanks

Im getting error while upgrading from ubuntu 14 to ubuntu 16. My development server is on ubuntu 14 is has no issue, but now i upgraded my local system with ubuntu 16, and i started getting this error for pip install --upgrade google-cloud-storage package.
Tried pip install --upgrade pyasn1-modules. but same error.

My pip freeze output:
aioredis==1.0.0
asgiref==2.3.0
asn1crypto==0.24.0
async-timeout==2.0.1
attrs==17.4.0
autobahn==18.4.1
Automat==0.6.0
boto3==1.7.7
botocore==1.10.7
cachetools==2.0.1
certifi==2018.4.16
cffi==1.11.5
channels==2.1.1
channels-redis==2.1.1
chardet==3.0.4
click==6.7
constantly==15.1.0
cryptography==2.2.2
daphne==2.1.1
decorator==4.3.0
Django==2.0.4
django-cors-headers==2.2.0
django-fcm==0.1.1
django-filter==1.1.0
django-material==1.2.3
django-simple-history==2.0
django-uuidfield==0.5.0
djangorestframework==3.8.2
djangorestframework-jwt==1.11.0
docutils==0.14
fcm-django==0.2.18
future==0.16.0
geocoder==1.38.1
geographiclib==1.49
geopy==1.13.0
google-api-core==1.1.1
google-auth==1.4.1
google-cloud-core==0.28.1
google-cloud-storage==1.8.0
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3
hiredis==0.2.0
hyperlink==18.0.0
idna==2.6
incremental==17.5.0
ipgetter==0.7
jmespath==0.9.3
msgpack==0.5.6
mysqlclient==1.3.12
Pillow==5.1.0
protobuf==3.5.2.post1
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycparser==2.18
pyfcm==1.4.5
PyJWT==1.6.1
python-dateutil==2.7.2
pytz==2018.4
ratelim==0.1.6
requests==2.18.4
requests-toolbelt==0.8.0
rsa==3.4.2
s3transfer==0.1.13
six==1.11.0
Twisted==17.9.0
txaio==2.10.0
urllib3==1.22
zope.interface==4.5.0

Any help please...

My guess is that this is perhaps because you have another (older) pyasn1 installed somewhere on the system and picked up accidentally.

Your pip freeze looks good from the versions perspective.

Thanks for the reply @etingof. As i have freshly installed ubuntu 16.04 on my local system and just installed pip dependencies on virtualenv. What other possible program may install(or use) pyasn1 in system?

You can try to import pyasn1_modules in Python's verbose mode too see which files it picks up:

$ python -v
>>> import pyasn1_modules
friendcolony@fc:~$ python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.7/site.pyc matches /usr/lib/python2.7/site.py
import site # precompiled from /usr/lib/python2.7/site.pyc
# /usr/lib/python2.7/os.pyc matches /usr/lib/python2.7/os.py
import os # precompiled from /usr/lib/python2.7/os.pyc
import errno # builtin
import posix # builtin
# /usr/lib/python2.7/posixpath.pyc matches /usr/lib/python2.7/posixpath.py
import posixpath # precompiled from /usr/lib/python2.7/posixpath.pyc
# /usr/lib/python2.7/stat.pyc matches /usr/lib/python2.7/stat.py
import stat # precompiled from /usr/lib/python2.7/stat.pyc
# /usr/lib/python2.7/genericpath.pyc matches /usr/lib/python2.7/genericpath.py
import genericpath # precompiled from /usr/lib/python2.7/genericpath.pyc
# /usr/lib/python2.7/warnings.pyc matches /usr/lib/python2.7/warnings.py
import warnings # precompiled from /usr/lib/python2.7/warnings.pyc
# /usr/lib/python2.7/linecache.pyc matches /usr/lib/python2.7/linecache.py
import linecache # precompiled from /usr/lib/python2.7/linecache.pyc
# /usr/lib/python2.7/types.pyc matches /usr/lib/python2.7/types.py
import types # precompiled from /usr/lib/python2.7/types.pyc
# /usr/lib/python2.7/UserDict.pyc matches /usr/lib/python2.7/UserDict.py
import UserDict # precompiled from /usr/lib/python2.7/UserDict.pyc
# /usr/lib/python2.7/_abcoll.pyc matches /usr/lib/python2.7/_abcoll.py
import _abcoll # precompiled from /usr/lib/python2.7/_abcoll.pyc
# /usr/lib/python2.7/abc.pyc matches /usr/lib/python2.7/abc.py
import abc # precompiled from /usr/lib/python2.7/abc.pyc
# /usr/lib/python2.7/_weakrefset.pyc matches /usr/lib/python2.7/_weakrefset.py
import _weakrefset # precompiled from /usr/lib/python2.7/_weakrefset.pyc
import _weakref # builtin
# /usr/lib/python2.7/copy_reg.pyc matches /usr/lib/python2.7/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.7/copy_reg.pyc
# /usr/lib/python2.7/traceback.pyc matches /usr/lib/python2.7/traceback.py
import traceback # precompiled from /usr/lib/python2.7/traceback.pyc
# /usr/lib/python2.7/sysconfig.pyc matches /usr/lib/python2.7/sysconfig.py
import sysconfig # precompiled from /usr/lib/python2.7/sysconfig.pyc
# /usr/lib/python2.7/re.pyc matches /usr/lib/python2.7/re.py
import re # precompiled from /usr/lib/python2.7/re.pyc
# /usr/lib/python2.7/sre_compile.pyc matches /usr/lib/python2.7/sre_compile.py
import sre_compile # precompiled from /usr/lib/python2.7/sre_compile.pyc
import _sre # builtin
# /usr/lib/python2.7/sre_parse.pyc matches /usr/lib/python2.7/sre_parse.py
import sre_parse # precompiled from /usr/lib/python2.7/sre_parse.pyc
# /usr/lib/python2.7/sre_constants.pyc matches /usr/lib/python2.7/sre_constants.py
import sre_constants # precompiled from /usr/lib/python2.7/sre_constants.pyc
import _locale # builtin
# /usr/lib/python2.7/_sysconfigdata.pyc matches /usr/lib/python2.7/_sysconfigdata.py
import _sysconfigdata # precompiled from /usr/lib/python2.7/_sysconfigdata.pyc
# /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.pyc matches /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py
import _sysconfigdata_nd # precompiled from /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.pyc
# /usr/lib/python2.7/sitecustomize.pyc matches /usr/lib/python2.7/sitecustomize.py
import sitecustomize # precompiled from /usr/lib/python2.7/sitecustomize.pyc
import encodings # directory /usr/lib/python2.7/encodings
# /usr/lib/python2.7/encodings/__init__.pyc matches /usr/lib/python2.7/encodings/__init__.py
import encodings # precompiled from /usr/lib/python2.7/encodings/__init__.pyc
# /usr/lib/python2.7/codecs.pyc matches /usr/lib/python2.7/codecs.py
import codecs # precompiled from /usr/lib/python2.7/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.7/encodings/aliases.pyc matches /usr/lib/python2.7/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib/python2.7/encodings/aliases.pyc
# /usr/lib/python2.7/encodings/utf_8.pyc matches /usr/lib/python2.7/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/lib/python2.7/encodings/utf_8.pyc
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib/python2.7/lib-dynload/readline.x86_64-linux-gnu.so", 2);
import readline # dynamically loaded from /usr/lib/python2.7/lib-dynload/readline.x86_64-linux-gnu.so
>>> import pyasn1_modules
import pyasn1_modules # directory /usr/lib/python2.7/dist-packages/pyasn1_modules
# /usr/lib/python2.7/dist-packages/pyasn1_modules/__init__.pyc matches /usr/lib/python2.7/dist-packages/pyasn1_modules/__init__.py
import pyasn1_modules # precompiled from /usr/lib/python2.7/dist-packages/pyasn1_modules/__init__.pyc
>>> 

any clue whats going wrong here?

(Virtual_EnvPy35_FC) friendcolony@fc:~$ python -v
import _frozen_importlib # frozen
import _imp # builtin
import sys # builtin
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
import 'posix' # <class '_frozen_importlib.BuiltinImporter'>
import _thread # previously loaded ('_thread')
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import _weakref # previously loaded ('_weakref')
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'zipimport' # <class '_frozen_importlib.BuiltinImporter'>
# installed zipimport hook
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/__init__.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__init__.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/__init__.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/codecs.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/codecs.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/codecs.cpython-35.pyc'
import '_codecs' # <class '_frozen_importlib.BuiltinImporter'>
import 'codecs' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468be16d8>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/aliases.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/aliases.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/aliases.cpython-35.pyc'
import 'encodings.aliases' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b7d1d0>
import 'encodings' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468be12e8>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/utf_8.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/utf_8.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/utf_8.cpython-35.pyc'
import 'encodings.utf_8' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b82f60>
import '_signal' # <class '_frozen_importlib.BuiltinImporter'>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/latin_1.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/latin_1.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/latin_1.cpython-35.pyc'
import 'encodings.latin_1' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b85a90>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/io.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/io.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/io.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/abc.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/abc.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/abc.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/_weakrefset.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc'
import '_weakrefset' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b88748>
import 'abc' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b85f28>
import 'io' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b85cc0>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/site.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/site.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/os.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/os.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/os.cpython-35.pyc'
import 'errno' # <class '_frozen_importlib.BuiltinImporter'>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/stat.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/stat.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/stat.cpython-35.pyc'
import '_stat' # <class '_frozen_importlib.BuiltinImporter'>
import 'stat' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b323c8>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/posixpath.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/posixpath.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/posixpath.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/genericpath.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/genericpath.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/genericpath.cpython-35.pyc'
import 'genericpath' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b35c88>
import 'posixpath' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b32710>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/_collections_abc.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc'
import '_collections_abc' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b3d320>
import 'os' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b9cb00>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/_bootlocale.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc'
import '_locale' # <class '_frozen_importlib.BuiltinImporter'>
import '_bootlocale' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b9cda0>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/types.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/types.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/types.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/functools.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/functools.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/functools.cpython-35.pyc'
import '_functools' # <class '_frozen_importlib.BuiltinImporter'>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/collections/__pycache__/__init__.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/collections/__init__.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/collections/__pycache__/__init__.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/operator.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/operator.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/operator.cpython-35.pyc'
import '_operator' # <class '_frozen_importlib.BuiltinImporter'>
import 'operator' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b26e48>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/keyword.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/keyword.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/keyword.cpython-35.pyc'
import 'keyword' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466f3c160>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/heapq.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/heapq.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/heapq.cpython-35.pyc'
import '_heapq' # <class '_frozen_importlib.BuiltinImporter'>
import 'heapq' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466f3c9b0>
import 'itertools' # <class '_frozen_importlib.BuiltinImporter'>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/reprlib.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/reprlib.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/reprlib.cpython-35.pyc'
import 'reprlib' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466f3ce48>
import '_collections' # <class '_frozen_importlib.BuiltinImporter'>
import 'collections' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b08898>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/weakref.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/weakref.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/weakref.cpython-35.pyc'
import 'weakref' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b2f198>
import 'functools' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468afc518>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/collections/__pycache__/abc.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/collections/abc.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/collections/__pycache__/abc.cpython-35.pyc'
import 'collections.abc' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b044e0>
import 'types' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468af6940>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/__init__.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__init__.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/__init__.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/warnings.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/warnings.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/__pycache__/warnings.cpython-35.pyc'
import 'warnings' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b04cf8>
import 'importlib' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468af6a20>
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/util.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/util.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/util.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/abc.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/abc.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/abc.cpython-35.pyc'
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/machinery.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/machinery.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/importlib/__pycache__/machinery.cpython-35.pyc'
import 'importlib.machinery' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466f61668>
import 'importlib.abc' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466f61240>
# /usr/lib/python3.5/__pycache__/contextlib.cpython-35.pyc matches /usr/lib/python3.5/contextlib.py
# code object from '/usr/lib/python3.5/__pycache__/contextlib.cpython-35.pyc'
import 'contextlib' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466ef1eb8>
import 'importlib.util' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466f5ccc0>
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/google
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/google
# destroy google
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/google
# destroy google
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/google
# destroy google
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/google/logging
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/google
# destroy google
# possible namespace for /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/zope
# /usr/lib/python3.5/__pycache__/sitecustomize.cpython-35.pyc matches /usr/lib/python3.5/sitecustomize.py
# code object from '/usr/lib/python3.5/__pycache__/sitecustomize.cpython-35.pyc'
# code object from /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/cp437.py
# could not create '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/cp437.cpython-35.pyc': PermissionError(13, 'Permission denied')
# wrote '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/encodings/__pycache__/cp437.cpython-35.pyc'
import 'encodings.cp437' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468af60f0>
# zipimport: found 77 names in '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/pyasn1-0.4.2-py3.5.egg'
import 'sitecustomize' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468af3f98>
import 'site' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0468b99080>
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
# extension module 'readline' loaded from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/lib-dynload/readline.cpython-35m-x86_64-linux-gnu.so'
# extension module 'readline' executed from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/lib-dynload/readline.cpython-35m-x86_64-linux-gnu.so'
import 'readline' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7f0466e9b7b8>
>>> import pyasn1_modules
# /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/pyasn1_modules/__pycache__/__init__.cpython-35.pyc matches /home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/pyasn1_modules/__init__.py
# code object from '/home/friendcolony/python_workspace/Virtual_EnvPy35_FC/lib/python3.5/site-packages/pyasn1_modules/__pycache__/__init__.cpython-35.pyc'
import 'pyasn1_modules' # <_frozen_importlib_external.SourceFileLoader object at 0x7f0466e9b978>
>>> 

Output of python -v verbose mode with virtualenv activated.

As a small note, I noticed that after updating pyasn1-modules, it was only pyasn1 itself that I had to declare explicitly on a higher version. Whatever version of pyasn1-modules was pulled in then worked, perhaps through a peer dependency of a more complex library, which is probably how a lot of people are running into this error.

pip install -U pyasn1_modules works for me.
But at the begining, I found "Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr" error, so pip install command actually didn't go into effect and I found https://askubuntu.com/a/880812 solution

pip install -U pyasn1_modules

worked for me

Suggestted pip updates fail to work with virtualenv for me. I had to export CLOUDSDK_PYTHON="/usr/bin/python3"