Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

3.3K
Visualizações
OSError: Could not find a suitable TLS CA certificate bundle

when making Api requests to binance , after building main.py to exe using pyinstaller, I get this error:

OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI76602\certifi\cacert.pem 

on the server where I run the bot and this on local machine:

OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\USER\PycharmProjects\pythonproject2\dist\cacert.pem 

the exact location of error for both is:

File "requests\adapters.py", line 227, in cert_verify

On the server the program had been running for over a week non stop with no problems until 2 days ago when I started getting the OSError. But only API calls caused the error with the program still running, the websockets were still receiving data.

I tried adding the code in the accepted answer of python requests can't find a folder with a certificate when converted to .exe

I also tried:

pip config set global.cert "path\to\cacert.pem"

with the correct path to cacert.pem, found using

python -c "import certifi; print(certifi.where())"

Non of that worked, currently the only workaround I found is to manually copy the cacert.pem file into the location where the OSError says it was looking for it (the cacert.pem file).

But I never had to do this before. Recently I updated my python version then downgraded again because of websocket problems. I did this by completely uninstalling python 3.10 and removing all references from PATH then reinstalled 3.9.7 and added all the PATH variables.

Does anyone have any idea what could be causing this? When I run the script in pycharm itself, I dont get this error, I also noticed that the global.cert is not the same path as OSError on local machine, but I have no idea how to change where it looks from cacert.pem file.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Ok so for now I have found a temporary solution. What was also happening was that where the program was looking for the cacert.pem file, there was no such file. So the workaround I found: In your project terminal, go to External Libraries -> Python3.9 -> site-packages -> certifi -> core.py

Then look for this Code:

import os

try:
    from importlib.resources import path as get_path, read_text

    _CACERT_CTX = None
    _CACERT_PATH = None

    def where():
    .............

Now, when you run the program, get the path where it looks for cacert.pem when it throws the error. Paste the cacert.pem file into Temp folder or Temp\2 etc.. then copy the path. Change the code to:

import os

try:
    from importlib.resources import path as get_path, read_text

    _CACERT_CTX = None
    _CACERT_PATH = "copied path"

    def where():
    .............

Also, I have compiled the exact same code on a new system and everything works fine. So more than likely the problem is with when I installed and uninstalled 3.10. Will update if I find the exact reason.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda