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.