通过pip安装tushare时,报错信息如下:
(base) [oracle@kiwi python]$ pip install tushare
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1108)'))': /simple/tushare/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1108)'))': /simple/tushare/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1108)'))': /simple/tushare/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1108)'))': /simple/tushare/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1108)'))': /simple/tushare/
Could not fetch URL https://pypi.org/simple/tushare/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/tushare/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1108)'))) - skipping
ERROR: Could not find a version that satisfies the requirement tushare (from versions: none)
ERROR: No matching distribution found for tushare
(base) [oracle@kiwi python]$ conda install tushare
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
主要原因是pip数据源是国外源,存在ssl认证的异常
可以通过制定国内源的方式,进行安装,如下
(base) [oracle@kiwi python]$ pip install tushare -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tushare
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a5/99/f6313e354621ba7c8d7155c1998004a8e63c6567d7e97922d518870f9008/tushare-1.2.61-py3-none-any.whl (214 kB)
|████████████████████████████████| 214 kB 1.0 MB/s
Requirement already satisfied: requests>=2.0.0 in /home/oracle/anaconda3/lib/python3.8/site-packages (from tushare) (2.20.0)
Collecting bs4>=0.0.1
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz (1.1 kB)
Collecting simplejson>=3.16.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/ac/1a7ac72f402f8978996dab444567092fcd56fde372b8a31226139c719819/simplejson-3.17.2-cp38-cp38-manylinux2010_x86_64.whl (137 kB)
|████████████████████████████████| 137 kB 9.6 MB/s
Collecting websocket-client>=0.57.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl (200 kB)
|████████████████████████████████| 200 kB 9.1 MB/s
Requirement already satisfied: lxml>=3.8.0 in /home/oracle/anaconda3/lib/python3.8/site-packages (from tushare) (4.5.2)
Requirement already satisfied: certifi>=2017.4.17 in /home/oracle/anaconda3/lib/python3.8/site-packages (from requests>=2.0.0->tushare) (2018.10.15)
Requirement already satisfied: idna<2.8,>=2.5 in /home/oracle/anaconda3/lib/python3.8/site-packages (from requests>=2.0.0->tushare) (2.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/oracle/anaconda3/lib/python3.8/site-packages (from requests>=2.0.0->tushare) (3.0.4)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /home/oracle/anaconda3/lib/python3.8/site-packages (from requests>=2.0.0->tushare) (1.24.1)
Requirement already satisfied: beautifulsoup4 in /home/oracle/anaconda3/lib/python3.8/site-packages (from bs4>=0.0.1->tushare) (4.9.1)
Requirement already satisfied: six in /home/oracle/anaconda3/lib/python3.8/site-packages (from websocket-client>=0.57.0->tushare) (1.11.0)
Requirement already satisfied: soupsieve>1.2 in /home/oracle/anaconda3/lib/python3.8/site-packages (from beautifulsoup4->bs4>=0.0.1->tushare) (2.0.1)
Building wheels for collected packages: bs4
Building wheel for bs4 (setup.py) ... done
Created wheel for bs4: filename=bs4-0.0.1-py3-none-any.whl size=1272 sha256=aeec79b11faf1e75d2417bb16115c909305dd0ecc08d41e38f500bf11384bc3a
Stored in directory: /home/oracle/.cache/pip/wheels/3b/fb/fd/c34d8e6cb51eabd4657dff7afb6e4b32196972175a33500555
Successfully built bs4
Installing collected packages: bs4, simplejson, websocket-client, tushare
Successfully installed bs4-0.0.1 simplejson-3.17.2 tushare-1.2.61 websocket-client-0.57.0
安装成功