IndexNotFoundException
pinecone.exceptions.IndexNotFoundException
Stack trace
pinecone.exceptions.IndexNotFoundException: Index 'my-index' not found. Please create the index before upserting vectors.
Why it happens
Pinecone requires that the index be created and fully initialized before any upsert operations. If the index name is misspelled, deleted, or not created, the client raises this exception when trying to upsert vectors.
Detection
Check for IndexNotFoundException in your upsert calls and verify the index existence via Pinecone dashboard or API before upserting.
Causes & fixes
The Pinecone index was never created or was deleted.
Create the index using Pinecone's create_index method before performing any upsert operations.
The index name used in the client does not match any existing index (typo or wrong environment).
Verify and correct the index name string in your code to exactly match the existing Pinecone index.
The Pinecone client is connected to the wrong environment or project where the index does not exist.
Ensure your Pinecone client is configured with the correct environment and project parameters matching where the index is created.
Code: broken vs fixed
import os
from pinecone import Pinecone
client = Pinecone(api_key=os.environ['PINECONE_API_KEY'], environment='us-west1-gcp')
index = client.Index('my-index')
# This line raises IndexNotFoundException if 'my-index' does not exist
index.upsert(vectors=[('id1', [0.1, 0.2, 0.3])]) import os
from pinecone import Pinecone
client = Pinecone(api_key=os.environ['PINECONE_API_KEY'])
# Create the index if it does not exist
if 'my-index' not in client.list_indexes():
client.create_index(name='my-index', dimension=3)
index = client.Index('my-index')
index.upsert(vectors=[('id1', [0.1, 0.2, 0.3])])
print('Upsert succeeded') Workaround
Catch IndexNotFoundException around the upsert call, then create the index programmatically before retrying the upsert operation.
Prevention
Always verify index existence at application startup or deployment, and automate index creation in your infrastructure setup to avoid missing indexes during runtime.