generative-ai-python
generative-ai-python copied to clipboard
AttributeError: 'NoneType' object has no attribute 'CLOSED'
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
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 :)
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.
This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!