好久没有使用mac写python代码了,今天打算写一个apscheduler例子,发现机器上并没有装该包,然后通过pip3下载发现报了如下错误:
Collecting apscheduler
Could not fetch URL https://pypi.python.org/simple/apscheduler/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) - skipping
Could not find a version that satisfies the requirement apscheduler (from versions: )
No matching distribution found for apscheduler
然后通过pip3 --version查看当前pip3版本为9.0.1版本,看网上都说需要升级pip版本,因为在python命令行执行import ssl并没有报错,所以就可以排除是本地ssl库没安装问题。
后来尝试升级pip,如下:
$ pip install --upgrade pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) - skipping
Requirement already up-to-date: pip in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
解决办法:
执行步骤如下:
$ curl https://bootstrap.pypa.io/get-pip.py | python3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1659k 100 1659k 0 0 288k 0 0:00:05 0:00:05 --:--:-- 513k
Collecting pip
Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 4.4MB/s
Collecting wheel
Downloading https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-19.0.3 wheel-0.33.1
再执行pip3 --version发现已经升级到19.0.3版本,OK!
执行pip3 install apscheduler,一切正常!