Pinecone Python SDK
Official Python SDK for the Pinecone managed vector database service. Supports serverless and pod-based indexes, vector upsert/query/delete, metadata filtering, namespaces, and integrated inference (embedding + reranking). REST client by default; optional gRPC transport for performance. Async support via PineconeAsyncio. Package was renamed from pinecone-client to pinecone in v5.1.0.
Common errors
-
ModuleNotFoundError: No module named 'pinecone'
cause The 'pinecone' package is not installed in the Python environment.fixInstall the Pinecone package using pip: 'pip install pinecone'. -
ImportError: cannot import name 'Pinecone' from 'pinecone'
cause Using an outdated version of the Pinecone SDK where the 'Pinecone' class is not available.fixUpgrade the Pinecone SDK to the latest version: 'pip install pinecone --upgrade'. -
AttributeError: module 'pinecone' has no attribute 'init'
cause Attempting to use the 'init' method, which is not present in newer versions of the Pinecone SDK.fixUse the 'Pinecone' class for initialization: 'from pinecone import Pinecone; pc = Pinecone(api_key=api_key)'. -
ImportError: cannot import name 'Client' from 'pinecone'
cause The 'Client' class has been removed or renamed in newer versions of the Pinecone SDK.fixUse the 'Pinecone' class for client initialization: 'from pinecone import Pinecone; pc = Pinecone(api_key=api_key)'. -
ImportError: cannot import name 'GRPCIndex' from 'pinecone'
cause The 'GRPCIndex' class has been removed or is not available in the current version of the Pinecone SDK.fixEnsure you have the latest version of the Pinecone SDK installed: 'pip install pinecone --upgrade'.
Warnings
- breaking pinecone.init() removed in v3.0. Raises AttributeError on any v3+ install. Affects all pre-2024 tutorials, YouTube courses, LangChain/LlamaIndex integration examples, and most LLM-generated Pinecone code.
- breaking Package renamed from pinecone-client to pinecone in v5.1.0. pinecone-client is now a frozen stub at v6.0.0. Having both installed causes import conflicts where the wrong version may be imported.
- breaking Python 3.9 dropped in v8.0.0 (released Nov 2025). Python 3.9 reached EOL Oct 2, 2025.
- breaking pinecone[grpc] had a breaking grpcio version bump in v4.0 to enable performance improvements. Environments with other grpcio consumers (e.g., TensorFlow, gRPC services) may see dependency conflicts.
- gotcha Serverless and pod indexes have different API surfaces. ServerlessSpec and PodSpec are not interchangeable. Attempting pod-only operations (e.g., configuring pod type, replicas) on a serverless index raises an API error.
- gotcha Index creation is asynchronous. pc.create_index() returns before the index is ready. Calling pc.Index('name') immediately after creation and then upsert/query may raise a 'not ready' or connection error.
- gotcha Metadata values must be strings, numbers, booleans, or lists of strings. Nested dicts, None values, and lists of mixed types are silently dropped or cause an API validation error.
- breaking Installing pinecone[grpc] requires a C compiler (e.g., gcc) because some of its dependencies (like grpcio or lz4) rely on C extensions that need to be built during installation. This can lead to an 'error: command gcc failed' in environments lacking build tools, such as minimal Docker images (e.g., Alpine Linux).
Install
-
pip install pinecone -
pip install 'pinecone[grpc]' -
pip install 'pinecone[asyncio]' -
pip uninstall pinecone-client && pip install pinecone
Imports
- Pinecone
import pinecone pinecone.init(api_key='YOUR_API_KEY', environment='us-east1-gcp')
from pinecone import Pinecone pc = Pinecone(api_key='YOUR_API_KEY')
- pinecone (package name)
pip install pinecone-client
pip install pinecone
Quickstart
from pinecone import Pinecone, ServerlessSpec
pc = Pinecone(api_key='YOUR_API_KEY') # or set PINECONE_API_KEY env var
# Create serverless index
if not pc.has_index('my-index'):
pc.create_index(
name='my-index',
dimension=1536,
metric='cosine',
spec=ServerlessSpec(cloud='aws', region='us-east-1'),
)
index = pc.Index('my-index')
# Upsert vectors
index.upsert(vectors=[
{'id': 'v1', 'values': [0.1] * 1536, 'metadata': {'source': 'doc1'}},
])
# Query
results = index.query(vector=[0.1] * 1536, top_k=5, include_metadata=True)
print(results)