Installation¶
Pinecone is tested on Python 3.6+.
We strongly recommend that you install Pinecone in a virtual environment. We think it’s good for Python hygiene. It’s really easy to start using virtual environments with one of these guides: [1], [2].
Installing Pinecone¶
pip install pinecone-client
A neat feature of Pinecone is that you can visualize the graphical representations
of your Pinecone services. If you plan to use Pinecone in a Jupyter notebook,
you should install the graph visualization tool
graphviz in your operating system.
Throughout the documentation, we assume that you have graphviz
installed.
# OSX
brew install graphviz
# Debian
sudo apt install graphviz
# RPM
sudo yum install graphviz
# Windows
winget install graphviz
Setting Up Pinecone¶
You will need a Pinecone API key for this step. If you haven’t received your API key, visit pinecone.io <https://www.pinecone.io/start/> to get started. You will receive an API key after registration.
The following command writes your Pinecone configurations to ~/.pinecone
.
pinecone init --api_key=YOUR_API_KEY
Alternatively, you can specify or override your API key when you import the Pinecone package:
import pinecone
pinecone.init(api_key="YOUR_API_KEY")
Hello, Pinecone!¶
import pinecone.graph
import pinecone.service
import pinecone.connector
service_name="hello-pinecone"
graph = pinecone.graph.IndexGraph() # create a graph
graph.view() # view the graph
pinecone.service.deploy(service_name, graph) # deploy the graph as a service
conn = pinecone.connector.connect(service_name) # connect to the service
conn.upsert(items=[("A", [1, 1, 1]), ("B", [1, 1, 1])]).collect() # insert vectors
conn.query(queries=[[0,1,0]], top_k=5).collect() # query
conn.info() # index info
pinecone.service.stop(service_name=service_name) # stop the service