googleapis / google-auth-library-python

Google Auth Python Library
https://googleapis.dev/python/google-auth/latest/
Apache License 2.0
778 stars 307 forks source link

ModuleNotFoundError: No module named 'requests.packages.urllib3' importing google.auth.transport.requests #1312

Closed eduardocorral closed 1 year ago

eduardocorral commented 1 year ago

Attempting to use the kubernetes client with

from kubernetes import client as kube_client

I get

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "xxxxxx", line 11, in <module>
    import xxxxx
  File "xxxxxx", line 7, in <module>
    from kubernetes import client as kube_client
  File "/home/xxxxxx/.local/lib/python3.9/site-packages/kubernetes/__init__.py", line 20, in <module>
    from . import config
  File "/home/xxxxxx/.local/lib/python3.9/site-packages/kubernetes/config/__init__.py", line 19, in <module>
    from .kube_config import (KUBE_CONFIG_DEFAULT_LOCATION,
  File "/home/xxxxxx/.local/lib/python3.9/site-packages/kubernetes/config/kube_config.py", line 29, in <module>
    import google.auth.transport.requests
  File "/home/xxxxxx/.local/lib/python3.9/site-packages/google/auth/transport/requests.py", line 39, in <module>
    from requests.packages.urllib3.util.ssl_ import (  # type: ignore
ModuleNotFoundError: No module named 'requests.packages.urllib3'; 'requests.packages' is not a package
>>> from requests.packages.urllib3.util.ssl_ import (  # type: ignore
...     create_urllib3_context,
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests.packages.urllib3'; 'requests.packages' is not a package

Python version

$ python --version
Python 3.9.14

urllib3

]$ pip show urllib3
Name: urllib3
Version: 1.26.5
...

requests

$ pip show requests
Name: requests
Version: 2.31.0
...

Edit: forgot google-auth version

]$ pip show google-auth
Name: google-auth
Version: 2.19.0
Summary: Google Authentication Library
...
clundin25 commented 1 year ago

Unable to reproduce. Used the following steps:

pyenv local 3.9.14
python -m venv env && source env/bin/activate
python -m pip install urllib3==1.26.5 requests==2.31.0 google-auth==2.19.0
python -c 'import google.auth.transport.requests' # no error
python -m pip install kubernetes
python -c 'from kubernetes import client as kube_client' # no error

Can you provide a reproduction in a docker image?

eduardocorral commented 1 year ago

Can't reproduce either on a clean OL9 image myself.

I'll check what the differences are with the actual instance in OCI.

clundin25 commented 1 year ago

Feel free to re-open once you have a repro @eduardocorral ! Thanks