ModuleNotFoundError: No module named 'weaviate.classes'; 'weaviate' is not a package

I am having a problem when importing weaviate.
Steps i have done:

  1. pip install weaviate-client (ver 4.10.2)
  2. Create Weaviate Cloud Cluter
  3. Run below code
import weaviate
from weaviate.classes.init import Auth

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Connect to Weaviate Cloud
client = weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=Auth.api_key(weaviate_api_key),
)

print(client.is_ready())

I got below error when executing the code:
Traceback (most recent call last):
File “C:\Users\KienCT6\Desktop\Study\Multimodal_LLM\weaviate.py”, line 1, in
import weaviate
File “C:\Users\KienCT6\Desktop\Study\Multimodal_LLM\weaviate.py”, line 3, in
from weaviate.classes.init import Auth
ModuleNotFoundError: No module named ‘weaviate.classes’; ‘weaviate’ is not a package

I have already install weaviate package, so i don’t know why it shows this error. Does anyone know how to fix this?

hi @Kien_Chau !!

Welcome to our community :hugs:

considering this error message, it seems that the weaviate package is not installed.

Are you sure the weaviate-client is installed at the same environment you are running this script?

hi @DudaNogueira,

Thank you for your reply.
I created conda env named myenv, and install weaviate-client using pip, then execute the code, and get below error.
I have tried to create new env, but the same error.
I also downgraded weaviate-client, but nothing changed.
And also restart my computer.

hi! can you check if the pip command you are using is the same one from the env you created?

You can usually check this with:

which pip

Thanks!