Reputation: 443
import yfinance as yf
msft = yf.Ticker("MSFT")
msft.info
I tried to print msft.info and got 'urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)' error. I tried to rerun the Install Certificates.command and Update Sheet.command but apparently it didn't work. Also after I reran them I got this massage: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/certifi-2021.5.30.dist-info.
Any advices how can I fix it?
Upvotes: 44
Views: 121823
Reputation: 1323
The above solution of Install Certificates.command works but it appears that what it's doing is really just pip install --upgrade certifi
.
Upvotes: 1
Reputation: 455
I've tried this and it works for me
import ssl
ssl._create_default_https_context = ssl._create_stdlib_context
Upvotes: 10
Reputation: 3787
I had the same problem in an virtual environment created with Poetry in Windows. I solved it removing the venv, then reinstalling all the deps.
Upvotes: 2
Reputation: 8488
Here are the steps for macOS:
/Applications/Python 3.x
(x
is the version you are running).Install Certificates.command
. It will open a terminal and install the certificate.In my case, I had to do this twice before it worked. Here is a screenshot from the Finder:
Upvotes: 170
Reputation: 31
If you have error [Errno 13] Permission denied: with InstallCertificates.command, open script in text editor, copy code and run in terminal with sudo su.
Upvotes: 1
Reputation: 1322
This answer got me from 2nd base home, but it skips over that the full path one would want is /Applications/
Python 3.x/Install Certificates.command
(which was called out in an other question's answer
(I was initially looking in the folder symlinked from /usr/local/bin/python3
)
Upvotes: 0
Reputation: 1
I had this problem using Anaconda with Python 3.9, and on Windows - the solution for me was in this answer: How to get and save LetsEncrypt certificates on Windows.
The process is:
For this part import the ISRG certs into the 'Certificates/Personal' folder, and import the Let's Encrypt R3 cert into the 'Trusted Root Certification Authorities/Certificates' folder.
Upvotes: 0
Reputation: 726
A quick google search returns the following: http://blog.wafrat.com/fixing-certificate_verify_failed-when-using-yfinances-ticker-info/
As explained in the website linked above, the issue is due to:
It turns out it's because I am running Python on Mac OS and I need to install some certificates (Mac OSX python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)).
And the solution is to:
So I opened Finder and navigated to Applications, Python 3.7, then ran Install Certificates.command. And it worked indeed!
Upvotes: 18