Python Forum
google-auth requirements.txt strange behavior - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: google-auth requirements.txt strange behavior (/thread-14866.html)



google-auth requirements.txt strange behavior - randalpinto - Dec-20-2018

I currently run a python process inside of a container and we have a custom site-packages where all the requirements.txt are installed. All works fine until today when I tried to install "https://github.com/googleapis/google-auth-library-python". Here's the strange behaviour:

If I install google-auth via requirements.txt into my custom site-packages I get an error: ImportError: No module named google.oauth2.credentials

However if I install it as "pip install google-auth", in which case it gets installed to /usr/local/lib/python2.7/site-packages/ it works fine.

Any ideas?


RE: google-auth requirements.txt strange behavior - Larz60+ - Dec-20-2018

If your system contains several versions of python, make sure the pip your are using matches the python version you want to use
you can find which python pip supports ts with
pip -V



RE: google-auth requirements.txt strange behavior - randalpinto - Dec-21-2018

Found the answer:

google-auth does not have a __init__.py in the "google" folder when installed from wheel so python 2.7 cannot import the oauth2 package inside this folder unless:

Because google-auth instead has a .pth file when it gets installed (google_auth-1.6.2-py3.7-nspkg.pth) this only gets executed if your site-packages is in the list of sites. So in order to make it work you have to:

import site
site.addsitedir('/path/to/my/site-packages')


RE: google-auth requirements.txt strange behavior - Larz60+ - Dec-21-2018

Note: python 2.7 will go away in 1 year 11 days 2 hours and 57 minutes
Perhaps it's time to think about python 3?
Current version 3.7.1