Skip to content

AttributeError: 'NoneType' object has no attribute 'CLOSED' #725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
satoshi-harimoto opened this issue Apr 1, 2025 · 2 comments
Open
Labels
p2 status:awaiting user response Awaiting a response from the author status:stale Issue/PR will be closed automatically if there's no further activity status:triaged Issue/PR triaged to the corresponding sub-team

Comments

@satoshi-harimoto
Copy link

Description of the bug:

For the code below,

# pip install -q -U google-genai
# pip install -U google-generativeai httpx
from google import genai
import os

google_api_key = os.getenv("GOOGLE_API_KEY")

client = genai.Client(api_key=google_api_key)

response = client.models.generate_content(
    model="gemini-2.0-flash",
    contents=["How does AI work?"]
)
print(response.text)

I have the error below:

Exception ignored in: <function SyncHttpxClient.__del__ at 0x118061f80>
Traceback (most recent call last):
  File "/opt/anaconda3/envs/autogen_test/lib/python3.12/site-packages/google/genai/_api_client.py", line 253, in __del__
  File "/opt/anaconda3/envs/autogen_test/lib/python3.12/site-packages/httpx/_client.py", line 228, in is_closed
AttributeError: 'NoneType' object has no attribute 'CLOSED'
Exception ignored in: <function AsyncHttpxClient.__del__ at 0x1188899e0>
Traceback (most recent call last):
  File "/opt/anaconda3/envs/autogen_test/lib/python3.12/site-packages/google/genai/_api_client.py", line 270, in __del__
  File "/opt/anaconda3/envs/autogen_test/lib/python3.12/site-packages/httpx/_client.py", line 228, in is_closed
AttributeError: 'NoneType' object has no attribute 'CLOSED'

My env is below:

# python --version
Python 3.12.9

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

@wanlin31
Copy link

wanlin31 commented Apr 5, 2025

I have tried to reproduce your error locally:
python --version
Python 3.12.9

Exactly the same as you run:

# pip install -q -U google-genai
# pip install -U google-generativeai httpx
from google import genai
import os

google_api_key = os.getenv("GOOGLE_API_KEY")

client = genai.Client(api_key=google_api_key)

response = client.models.generate_content(
    model="gemini-2.0-flash",
    contents=["How does AI work?"]
)
print(response.text)

I actually got the text:

Output:

Okay, let's break down how AI works. It's a vast and complex field, so I'll give you a general overview and then dive into specific approaches:

**Core Idea: Mimicking Human Intelligence**
...

Can you help to confirm that you still see the error?

Thank you :)

@wanlin31 wanlin31 added p3 p2 status:triaged Issue/PR triaged to the corresponding sub-team status:awaiting user response Awaiting a response from the author and removed p3 labels Apr 5, 2025
Copy link

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

@github-actions github-actions bot added the status:stale Issue/PR will be closed automatically if there's no further activity label Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 status:awaiting user response Awaiting a response from the author status:stale Issue/PR will be closed automatically if there's no further activity status:triaged Issue/PR triaged to the corresponding sub-team
Projects
None yet
Development

No branches or pull requests

2 participants