NameError: name 'PodSpec' is not defined

hi,

Can some one help me when i am trying pinecone i am getting this error message "NameError: name 'PodSpec' is not defined" for the code pc = Pinecone(api_key=PINECONE_API_KEY)

    if USE_SERVERLESS:
        spec = ServerlessSpec(cloud='aws', region='us-west-2')
    else:
        # Ensure PINECONE_ENV is set for non-serverless configurations
        if not PINECONE_ENV:
            raise ValueError("PINECONE_ENV must be set when not using serverless configuration.")
        spec = PodSpec(environment=PINECONE_ENV)

    # Define the index name
    index_name = "stre"

    # Check if index already exists
    if index_name not in pc.list_indexes().names():
        # If it does not exist, create index
        pc.create_index(
            name=index_name,
            dimension=1536,  # dimensionality of text-embedding-ada-002
            metric='cosine',
            spec=spec
        )
        # Wait for index to be initialized
        time.sleep(1)

    # Connect to index
    index = pc.Index(index_name)
    index.describe_index_stats().

Thank you

Hi @btejasri1996,

Can you provide the full stacktrace of the error you’re getting? Just so we’re not missing anything.

Also, make sure you’re importing the ServerlessSpec and PodSpec classes.

from pinecone import Pinecone, ServerlessSpec, PodSpec