I've installed the Google Cloud SDK and want the code I'm writing to pass pylint. Unfortunately any time I import anything from google.* I get an error:
E: 10, 0: No name 'cloud' in module 'path/to/my/current/module.google' (no-name-in-module)
E: 10, 0: Unable to import 'google.cloud' (import-error)
Versions:
$: pylint --version
pylint 1.7.0,
astroid 1.5.0
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4]
If I put a hook in pylint to print out the sys path I get nothing interesting. The google-cloud-sdk is in /usr/local/lib/python2.7/dist-packages
so it should be able to find it.
['/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/backports.functools_lru_cache-1.3-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/configparser-3.5.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/singledispatch-3.4.0.3-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/editdistance-0.3.1-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/mccabe-0.6.1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/astroid-1.5.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/wrapt-1.10.10-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/lazy_object_proxy-1.2.2-py2.7-linux-x86_64.egg', '/usr/lib/python2.7/dist-packages']
Does anyone know why it is looking in my local path for the "google" module and how I can fix it?
Updates with more detail about my environment:
The Google Cloud SDK modules in question are located at:
/usr/local/lib/python2.7/dist-packages/google
if I ls
that directory it shows:
api auth cloud gapic gax iam ...
and if I follow down those paths all the modules are in the places I'd expect them to be given the import statements.
However, there are no __init__.py
files, which makes me think that they're using implicit namespace packages. So it seems like the relevant question here is: how to make pylint recognize an implicit namespace package? The docs say it should "just work":
https://docs.pylint.org/en/latest/user_guide/run.html?highlight=re
For the record, the same problem shows up when using mypy.