I installed yfinance in Spyder (Python 3.7) but when I make a basic call, such as:
import yfinance as yf
df_yahoo = yf.download('AAPL',
start='2000-01-01',
end='2010-12-31',
progress=False)
print(df_yahoo)
I get an error message:
Exception in thread Thread-9: Traceback (most recent call last):
File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 672, in urlopen chunked=chunked, File "c:\users/miniconda3\lib\site-packages\urllib3\connectionpool.py", line 376, in _make_request self._validate_conn(conn) File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 994, in validate_conn conn.connect() File "c:\users\miniconda3\lib\site-packages\urllib3\connection.py", line 360, in connect ssl_context=context, File "c:\users\miniconda3\lib\site-packages\urllib3\util\ssl.py", line 370, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "c:\users\miniconda3\lib\ssl.py", line 423, in wrap_socket session=session File "c:\users\miniconda3\lib\ssl.py", line 870, in _create self.do_handshake() File "c:\users\miniconda3\lib\ssl.py", line 1139, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "c:\users\miniconda3\lib\site-packages\requests\adapters.py", line 449, in send timeout=timeout File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py", line 720, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "c:\users\miniconda3\lib\site-packages\urllib3\util\retry.py", line 436, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max retries exceeded with url: /v8/finance/chart/AAPL?period1=946681200&period2=1293750000&interval=1d&includePrePost=False&events=div%2Csplits (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "c:\users\miniconda3\lib\threading.py", line 926, in _bootstrap_inner self.run() File "c:\users\miniconda3\lib\threading.py", line 870, in run self._target(*self._args, **self.kwargs) File "c:\users\miniconda3\lib\site-packages\multitasking_init.py", line 102, in _run_via_pool return callee(*args, **kwargs) File "c:\users\miniconda3\lib\site-packages\yfinance\multi.py", line 167, in _download_one_threaded actions, period, interval, prepost, proxy, rounding) File "c:\users\miniconda3\lib\site-packages\yfinance\multi.py", line 182, in _download_one rounding=rounding, many=True) File "c:\users\miniconda3\lib\site-packages\yfinance\base.py", line 150, in history data = _requests.get(url=url, params=params, proxies=proxy) File "c:\users\miniconda3\lib\site-packages\requests\api.py", line 76, in get return request('get', url, params=params, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\sessions.py", line 530, in request resp = self.send(prep, **send_kwargs) File "c:\users\miniconda3\lib\site-packages\requests\sessions.py", line 643, in send r = adapter.send(request, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max retries exceeded with url: /v8/finance/chart/AAPL?period1=946681200&period2=1293750000&interval=1d&includePrePost=False&events=div%2Csplits (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)')))
Moreover, Spyder seems to get stuck in some sort of loop and I have to manually interrupt it.
Can anyone help me here?
Many thanks