'requests.packages.urllib3.exceptions.SSLError: [Error 2] no such file or directory
Have some code, it works with raw code but once i turned it into a executable with pyinstaller i get the requests.packages.urllib3.exceptions.SSLError: [Error 2] no such file or directory
it always works with raw code but not with pyinstaller
tried using requests from both python 2 and python3, tried on multiple PCs.
i expect it to execute the code when using a .exe with pyinstaller
Solution 1:[1]
Finally I found a solution by using certifi to resolve the full path to the 'cacert.pem' cert. And use it in request:
import requests
import certifi
req_url = "https://jsonplaceholder.typicode.com/todos/1"
response = requests.get(req_url, timeout=10, verify=certifi.where()).json()
print(response)
If you use another cert or want to move to final binary it can be copied into pyinstaller too and use it into verify parameter.
Solution 2:[2]
Post some code, without it I am going blindly. But i can guest that you have somewhere in your code relative(like ./file), while everything is in your original directory(raw code) it works, but after compiling,programm can't find it
Solution 3:[3]
I found the solution
Using auto-py-to-exe and pyinstaller to convert to exe.
Click in "on file" button use "one directory" option.
Then you have to go to your python's directory and find the directory "requests".
Copy this directory ("requests") to your app directory created with auto-py-to-exe.
It's done.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | GoNzCiD |
| Solution 2 | Misieq |
| Solution 3 | AlexRE |
