Unable to push the vector embedding to my pinecone index

Unable to push my vector embedding to pinecone DB

as the previous version is depreciated

my previous code which works fine but now throwing error

#Initializing the Pinecone


#Creating Embeddings for Each of The Text Chunks & storing

docsearch=Pinecone.from_texts([t.page_content for t in text_chunks], embeddings, index_name=index_name)

Hi @saliksajjad! Welcome to the Pinecone forum.

If you are using Python client version 3.0.0 or higher, initializing your client works a little differently. Can you try this?

from pinecone import Pinecone

pc = Pinecone(api_key=PINECONE_API_KEY')
1 Like

Hi @jesse ! thanks for your reply
I used python 3.9 and langchain 0.0.225 and pinecone-client 3.0.0.dev4

The code which you shared is running but I face an issue while pushing my text chunks along with embedding to pinecone db, if you saw my code snip you will get it.

@saliksajjad Please share how you import and name LangChain and Pinecone packages. In your screenshot, this information is not visible.

If it’s the lines you’ve commented out, please let us know. In that case, you must run from langchain_pinecone import PineconeVectorStore. LangChain has since deprecated other versions of its integration package with Pinecone. See LangChain’s API Reference for more details.

@zeke_pinecone initially I used:

from langchain.vectorstores import Pinecone ## langchain version 0.0.225
import pinecone ## pip install pinecone-client

then used code:

pinecone.init(api_key, env_key)
docvector = Pinecone.from_texts([t.page_content for t in text_chunks], embeddings, index)

I got error then I tried to use with:

from langchain_pinecone import Pinecone ## pip install langchain-pinecone

then used code as below:

index =pc.Index("Index_name")

docvect = Pinecone.from_texts([t.page_content for t in text_chunks], embeddings, index)

got error api_key can’t find.

In both the cases, there I found error, please provide the right library and code to use for pushing my vector embeddings to pinecone DB.

Please see my message above for details of the correct LangChain package. The complete imports you’ll need are below.

from pinecone import Pinecone
from langchain_pinecone import PineconeVectorStore

The following resources have up-to-date imports and may be helpful:

@zeke_pinecone please check below I got this error.


@saliksajjad Please confirm that you are using the latest versions of each package. For LangChain, this will be v0.1.16. For the Pinecone Python client, this will be v3.2.2.

If you are not using these versions, you will not be able to import the correct classes:

from pinecone import Pinecone
from langchain_pinecone import PineconeVectorStore

Once this is confirmed, plase ensure that you have successfully initialized the Pinecone client. You can do so by running the following code:

from pinecone import Pinecone

pc = Pinecone(api_key=PINECONE_API_KEY)


The list_indexes() operation should return a list of the active indexes in the project from which you grabbed the API key.

@zeke_pinecone thanks it was resolved as only mistake was to use os.eniron

1 Like