google/importlab

importlab interacts badly with `pyenv local`

Closed this issue · 4 comments

$ virtualenv testbug
New python executable in testbug/bin/python
Installing setuptools, pip, wheel...done.
$ source testbug/bin/activate
$ echo "import rsa" > /tmp/test_rsa.py
$ pip install pytype
Collecting pytype
Collecting six (from pytype)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting importlab (from pytype)
Collecting pyyaml>=3.11 (from pytype)
Collecting networkx (from importlab->pytype)
Collecting decorator>=4.1.0 (from networkx->importlab->pytype)
  Using cached https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Installing collected packages: six, decorator, networkx, importlab, pyyaml, pytype
Successfully installed decorator-4.3.0 importlab-0.2.1 networkx-2.1 pytype-2018.8.10 pyyaml-3.13 six-1.11.0
$ pytype -P /tmp /tmp/test_rsa.py
Analyzing 1 sources with 0 dependencies
File "/tmp/test_rsa.py", line 1, in <module>: Can't find module 'rsa'. [import-error]

For more details, see https://github.com/google/pytype/blob/master/docs/errors.md#import-error.
$ pip install rsa
Collecting rsa
  Using cached https://files.pythonhosted.org/packages/e1/ae/baedc9cb175552e95f3395c43055a6a5e125ae4d48a1d7a924baca83e92e/rsa-3.4.2-py2.py3-none-any.whl
Collecting pyasn1>=0.1.3 (from rsa)
  Using cached https://files.pythonhosted.org/packages/d1/a1/7790cc85db38daa874f6a2e6308131b9953feb1367f2ae2d1123bb93a9f5/pyasn1-0.4.4-py2.py3-none-any.whl
Installing collected packages: pyasn1, rsa
Successfully installed pyasn1-0.4.4 rsa-3.4.2
$ pytype -P /tmp /tmp/test_rsa.py
Analyzing 1 sources with 0 dependencies
File "/tmp/test_rsa.py", line 1, in <module>: Can't find module 'rsa'. [import-error]

For more details, see https://github.com/google/pytype/blob/master/docs/errors.md#import-error.
$ python /tmp/test_rsa.py
$ importlab /tmp/test_rsa.py --unresolved
Unresolved dependencies:
  rsa

I'm seeing this issue when trying to run pytype over https://github.com/GoogleCloudPlatform/google-auth-library-python

Other libraries it can't seem to find:

  • cachetools
  • cryptography
  • grpc
  • pyasn

This issue seems to arise when using pyenv local. Setting the python version using pyenv shell fixes it.

seems to be working with pyenv local now