Python Forum
google-auth requirements.txt strange behavior
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
google-auth requirements.txt strange behavior
#1
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?
Reply
#2
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
Reply
#3
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')
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  strange behavior of chess library in Python max22 1 267 Jan-18-2024, 06:35 PM
Last Post: deanhystad
  Problem with code / audio is playing randomly, not matching csv requirements Daniel_kcr 2 579 Sep-07-2023, 05:09 PM
Last Post: deanhystad
  when package built, requirements not installed sabuzaki 1 703 Apr-07-2023, 09:01 AM
Last Post: sabuzaki
  Program running on RPi 3b+ Very Strange Behavior - Out of Bound Index MadMacks 26 3,055 Mar-07-2023, 09:50 PM
Last Post: MadMacks
  auth - URL SUN 2 1,478 May-20-2022, 07:50 AM
Last Post: SUN
  Strange write()/File behavior kaega2 2 1,654 Jan-28-2022, 02:53 AM
Last Post: kaega2
  What to do when the requirements.txt file does not work Led_Zeppelin 2 6,172 Nov-04-2021, 06:51 PM
Last Post: snippsat
  IBM Watson: Handshake status 403 Forbidden or No section: 'auth' groschat 1 2,757 May-07-2021, 03:44 PM
Last Post: jefsummers
  Examples of Customer requirements ComputerAstronaut 1 1,807 Dec-08-2020, 03:22 AM
Last Post: Larz60+
  requirements file tdwinfre 7 2,685 Nov-06-2020, 06:01 AM
Last Post: tdwinfre

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020