Anyone facing init, mssing api keys,from_texts, from_documents, vectorstore, langchain_pinecone not found errors

First of all guys anyone facing init error :
Pinecone has recently updated there library due to which you wont be able to use the old deprecated methods.
to initialize your pinecone →

import pinecone
from pinecone import Pinecone,ServerlessSpec

use these import statements
then to initialize →

pc = Pinecone(api_key=PINECONE_API_KEY) //use this
index_name = "testing" //your index name
index = pc.Index(index_name) //using Index method to basically configure your (this part is necessary to avoid api key missing errors too)

(you can see this for more reference)

one more thing to keep in mind while facing missing api keys →

(note anyone facing the api key missing config error , you will have to set your api keys thru os(operating system) module in python , you can do this by

PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY','your_api_key')
PINECONE_API_ENV = os.environ.get('PINECONE_API_ENV','gcp-starter')

For anyone who’s facing from_texts or from_docs method not available error :

from langchain.vectorstores import Pinecone
docsearch = Pinecone.from_texts([t.page_content for t in text_chunks], embedding, index_name=index_name)

// previously you used to use your methods like this importing Pinecone module from langchain.vectorstores and using this directly to store your data inside pinecode index in form of vector embeddings. Now you cant use this :
You will have to use PineconeVectorStore class provided by langchain_pinecone →

from langchain_pinecone import PineconeVectorStore
docsearch = PineconeVectorStore.from_texts(texts = your_text_string, embedding=embedding, index_name=index_name)
//same for from_docs 


use this to set up your environment , important to download the versions they have provided
restart your kernel and try again

now if you still face error :slight_smile:
please do what i did and it worked for me. i created a new file with a new python kernel (3.8.19)
use this kernel and environment provided by them (this is imp) and your issue will be resolved. it worked for me.

feel free to comment down in case you receive any more errors

I tried everything…I still get invalid API…omg…this is driving me crazy

from pinecone import Pinecone, ServerlessSpec, PodSpec  
pinecone_api_key = os.environ.get('PINECONE_API_KEY')
openai_api_key = os.environ.get('OPENAI_API_KEY')
pc = Pinecone(api_key='PINECONE_API_KEY')

index = pc.Index(index_name) 
UnauthorizedException: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'X-Cloud-Trace-Context': '4e0d79a2b2ad74590f78fb9290b228ab', 'Date': 'Mon, 22 Apr 2024 17:08:43 GMT', 'Content-Type': 'text/html', 'Server': 'Google Frontend', 'Content-Length': '15', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'})
HTTP response body: Invalid API Key

@anithakse1975 you’re assigning your environment variable PINECONE_API_KEY to the new variable pinecone_api_key. But then when you connect to Pinecone, you’re using the string “PINECONE_API_KEY”, not either of those variables.

Try replacing this line:

pc = Pinecone(api_key=‘PINECONE_API_KEY’)


pc = Pinecone(api_key=pinecone_api_key)
1 Like

that worked…Thank you…I have hit another issue

[quote=“anithakse1975, post:1, topic:5308, full:true”]

pc = Pinecone(api_key=pinecone_api_key)
index = pc.Index(index_name)

embeddings = OpenAIEmbeddings(
from langchain.vectorstores import Pinecone as PineconeStore
[t.page_content for t in textchunk],

PineconeConfigurationError: You haven’t specified an Api-Key.
I am getting missing API for docsearch…any help pls…I have been at this issue …seems like forever!

Can you share the full stacktrace of the error?

Also, just fyi and probably unrelated, there’s a new version of Langchain that uses Pinecone 3.0. I recommend upgrading to make sure you’re taking advantage of all the recent improvements.

hey try console logging the api key pinecone one which you passed. Sometimes things don’t change , i faced incorrect api key error right now and while debugging and printing i found out that os module wasn’t updating the api key which i specified irrespective of running the command again and again in my jupyter notebook . So i restarted the kernel and ran all commands. It solved the issue.

1 Like

can you help me fix this error:

retrieve = PineconeVectorStore.from_existing_index(
qa = RetrievalQA.from_chain_type(
retriever = vectorstore_from_docs.as_retriever(),

Can’t instantiate abstract class BaseRetriever with abstract methods _aget_relevant_documents, _get_relevant_documents (type=type_error)

Hi @rex718947,

If you are still facing this issue, could I ask you to open a new / separate forum thread describing your issue and including:

  • The version of LangChain you’re using
  • All relevant code
  • The full stack trace / error you’re getting back

I was able to find this GitHub issue in the meantime which looks like it could be related: Potential Bug in Can't instantiate abstract class BaseRetriever with abstract method _get_relevant_documents · Issue #13624 · langchain-ai/langchain · GitHub

Thanks so much