googleapis / google-auth-library-python

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

I can't load any package #1426

Closed CureSaba closed 8 months ago

CureSaba commented 8 months ago

Environment details

Steps to reproduce

  1. Install google-auth
  2. Try import module

image There is a file in the pip directory but I can't load it

parthea commented 8 months ago

Can you please share the output after running which python?

Please also try running python -m pip install google-auth.

Please also check if the path that you see after running which python appears in in the output of this command

import sys
sys.path
CureSaba commented 8 months ago

image which python gives an error

parthea commented 8 months ago

Sorry about that. where python may work , as which python is for unix.

Please also try running

python -c "import os, sys; print(os.path.dirname(sys.executable))"

Also try:

python -m pip install google-auth --ignore-installed
CureSaba commented 8 months ago

image

parthea commented 8 months ago

@clundin25 Do you have availability to reproduce the issue in Windows Power Shell?

clundin25 commented 8 months ago

I was not able to reproduce.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\clundin> python --version
Python 3.12.0
PS C:\Users\clundin> python -m pip install google-auth
Collecting google-auth
  Downloading google_auth-2.24.0-py2.py3-none-any.whl.metadata (4.7 kB)
Collecting cachetools<6.0,>=2.0.0 (from google-auth)
  Obtaining dependency information for cachetools<6.0,>=2.0.0 from https://files.pythonhosted.org/packages/a2/91/2d843adb9fbd911e0da45fbf6f18ca89d07a087c3daa23e955584f90ebf4/cachetools-5.3.2-py3-none-any.whl.metadata
  Downloading cachetools-5.3.2-py3-none-any.whl.metadata (5.2 kB)
Collecting pyasn1-modules>=0.2.1 (from google-auth)
  Downloading pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.3/181.3 kB 2.7 MB/s eta 0:00:00
Collecting rsa<5,>=3.1.4 (from google-auth)
  Downloading rsa-4.9-py3-none-any.whl (34 kB)
Collecting pyasn1<0.6.0,>=0.4.6 (from pyasn1-modules>=0.2.1->google-auth)
  Obtaining dependency information for pyasn1<0.6.0,>=0.4.6 from https://files.pythonhosted.org/packages/d1/75/4686d2872bf2fc0b37917cbc8bbf0dd3a5cdb0990799be1b9cbf1e1eb733/pyasn1-0.5.1-py2.py3-none-any.whl.metadata
  Downloading pyasn1-0.5.1-py2.py3-none-any.whl.metadata (8.6 kB)
Downloading google_auth-2.24.0-py2.py3-none-any.whl (183 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 183.8/183.8 kB 10.8 MB/s eta 0:00:00
Downloading cachetools-5.3.2-py3-none-any.whl (9.3 kB)
Downloading pyasn1-0.5.1-py2.py3-none-any.whl (84 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.9/84.9 kB 5.0 MB/s eta 0:00:00
Installing collected packages: pyasn1, cachetools, rsa, pyasn1-modules, google-auth
Successfully installed cachetools-5.3.2 google-auth-2.24.0 pyasn1-0.5.1 pyasn1-modules-0.3.0 rsa-4.9

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
PS C:\Users\clundin> python -c 'import google.auth'
PS C:\Users\clundin> python -c 'import google.oauth2'
PS C:\Users\clundin>
clundin25 commented 8 months ago

I believe test.py should work after you add import google.oauth2.

CureSaba commented 8 months ago

image It works but why? I think import google will load all package

clundin25 commented 8 months ago

Here is a document outlining importing for Python 3.12. https://docs.python.org/3/reference/import.html.

I think the behavior is likely because google is a namespace package, but I did not take a close look.

CureSaba commented 8 months ago

Thank you for support