Local testing yields OSError: Could not find a suitable TLS CA certificate

Hello Streamlit team, thank you for the great work.
While I do know there is a topic on a similar issue OSError: Could not find a suitable TLS CA certificate bundle, invalid path
None of the suggestions there work for me. I am creating this new topic because the other is closed.

In my case, I am merely doing local testing and not involved in deployment where the issue occured in the other topic.

I have the certificate (.crt) as REQUESTS_CA_BUNDLE in the .env file.

I am using vscode.

on run, the OpenAIEmbeddings() works fine. But it’s the load in streamlit that fails with error.

I get the error even after copy pasting the certificate content to ~\Python39\lib\site-packages\certifi\cacert.pem
I am using Python 3.9

Streamlit community, your help will be greatly appreciated.

Sincerely,
Martin
Below are logs:

2023-05-13 21:58:27.153 Uncaught app exception
Traceback (most recent call last):
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "C:\MIDS\langChainPlay\chatapp.py", line 83, in <module>
    if __name__ == '__main__': main()
  File "C:\MIDS\langChainPlay\chatapp.py", line 50, in main
    knowledge_base = FAISS.from_texts(chunks, embeddings)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\vectorstores\faiss.py", line 384, in from_texts
    embeddings = embedding.embed_documents(texts)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\embeddings\openai.py", line 269, in embed_documents
    return self._get_len_safe_embeddings(texts, engine=self.deployment)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\embeddings\openai.py", line 206, in _get_len_safe_embeddings
    response = embed_with_retry(
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\embeddings\openai.py", line 63, in embed_with_retry
    return _embed_with_retry(**kwargs)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\tenacity\__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\tenacity\__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\tenacity\__init__.py", line 314, in iter
    return fut.result()
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 433, in result
    return self.__get_result()
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 389, in __get_result
    raise self._exception
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\tenacity\__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\embeddings\openai.py", line 61, in _embed_with_retry
    return embeddings.client.create(**kwargs)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\embedding.py", line 33, in create
    response = super().create(*args, **kwargs)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 220, in request
    result = self.request_raw(
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\openai\api_requestor.py", line 520, in request_raw
    result = _thread_context.session.request(
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 458, in send
    self.cert_verify(conn, request.url, verify, cert)
  File "C:\Users\hi.bye\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 261, in cert_verify
    raise OSError(
OSError: Could not find a suitable TLS CA certificate bundle, invalid path: ..\ZscalerRootCertificate-2048-SHA256.crt

None of the suggestions there work for me.
…
I am using Python 3.9

Looks like you didn’t follow the only suggestion given in the linked thread.

Ah!!! Thank you so much @Goyo . I did read that. But I wrongly assumed it only mattered if you are doing a deployment. Thank you again. I just installed Python 3.10 and it works. Thanks