1

I have been working on a program that shows the weather using python and thought I would try setting it up as an exe for easy installation on other devices. However every time I put in a location to search for using the exe GUI, I get this in the terminal window that opens with the program window:

Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1892, in __call__
  File "getWeather.py", line 132, in <lambda>
  File "getWeather.py", line 45, in open_weather
  File "requests\api.py", line 75, in get
  File "requests\api.py", line 61, in request
  File "requests\sessions.py", line 529, in request
  File "requests\sessions.py", line 645, in send
  File "requests\adapters.py", line 417, in send
  File "requests\adapters.py", line 228, in cert_verify
OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\pcusername\AppData\Local\Temp\_MEI118802\certifi\cacert.pem

I have been trying to figure out what the problem is, but haven't been able to find anything to get it working. If anyone can help figure this out I would appreciate it. Also, let me know if any more context/code is needed or if I did anything wrong regarding the post, as it is my first time having to post on stack overflow.

Note, this is using: windows 11, python 3.9, pycharm 2021.2.2, pyinstaller for exe creation

10
  • 1
    What package/library are you using to create your exe? Commented Jan 5, 2022 at 2:42
  • I am using pyinstaller to create the exe Commented Jan 5, 2022 at 2:45
  • Does this help? stackoverflow.com/questions/46119901/… Commented Jan 5, 2022 at 2:50
  • Doesn't seem to be, throws this: OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\rltbv\PycharmProjects\API Weather\dist\cacert.pem, that is if I put it at the beginning of my main py file Commented Jan 5, 2022 at 2:53
  • The file certifi\cacert.pem is included in the executable generated by PyInstaller v4.7 and requests v2.27.0 in my Python 3.8.12 in Windows 7. Commented Jan 5, 2022 at 3:00

1 Answer 1

1

Ok ended up figuring it out: This method does work: (The top answer) python requests can't find a folder with a certificate when converted to .exe

I was however missing the cacert.pem file still, which gave the error when I tried this fix initially. What ended up working is finding the cacert.pem in the mypycharmproject\venv\Lib\site-packages\certifi folder and then copying it to the dist folder where the exe is located.

Thank you for your help everyone!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.