Using requests in Python3 Windows via Pycharm, and receiving SSL Module Not Available Error
I've spent hours trying to figure out what could be causing this. I've reinstalled Anaconda, and I am completely stuck. When running the following
def Earlybird(daycount):
url = 'https://msft.com'
response = requests.get(url)
print(response)
Earlybird()
I receive the error
requests.exceptions.SSLError: HTTPSConnectionPool(host='msft.com',
port=443): Max retries exceeded with url: / (Caused by SSLError("Can't
connect to HTTPS URL because the SSL module is not available."))
I have no idea what could be causing this. As Anaconda is a recent install, I would assume everything would be up-to-date, so I'm unsure if this is pointing to the wrong SSL ? I am a bit new to python, so thanks for your patience. -
Reinstalling python based on instructions from here solved this problem for me: How can I install a previous version of Python 3 in macOS using homebrew?
I had a similar problem on Windows 10 using Conda and Python 2.7.2
After trying many, many solutions I came across this response which suggested that there is an issue with openssl in that build.
Once I downgraded python to 3.7.1 (build h33f27b4_4) everything worked fine.
going to the website: gives me following information from developer tool and looking at headers. (right click --> inspect. then open network tab and check headers)
So we see we need to perform a request to HTTP, not HTTPS.
Windows Users need to set below paths:
..\Anaconda3
..\Anaconda3\scripts
..\Anaconda3\Library\bin
Per user:
System wide (requires restart):
There is no need to add paths to environment if you use the Anaconda Prompt.
Start the Anaconda prompt change to your directory and run your script or start your editor from there. This will ensure you are in the full Anaconda environment and the SSL error will stop.
Whats the difference between command prompt and Anaconda Prompt? See this SO answer to what is the difference between command prompt and anaconda prompt.
I use VSCode to edit and debug and the only solution that worked for me was to edit the environment variables in windows.. Apparently this causes issues but I'm not sure what they are.
Running from the Anaconda prompt (as suggested by sayth) was NOT an option for me. Or perhaps the suggestion was to run the anaconda prompt and the from the anaconda prompt somehow start VSCode. Doesn't sound like a reasonable request.
This appears to be a long running chronic issue without a definitive global answer that works for everyone.