600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > Mac 安装 Python 多版本

Mac 安装 Python 多版本

时间:2019-04-17 20:45:50

相关推荐

Mac 安装 Python 多版本

Mac 的安装方式和两个版本共存的出现的问题:

Python 安装包下载地址:/downloads/

如果要Python 2x 和 Python 3x 同时拥有的话,我是这样做的:

1. 分别安装两个安装包。

2. 安装完成之后配置环境使得能在终端切换Python版本:

2.1 打开终端(terminal),输入:sudo vi ~/.bashrc;2.2 在弹出的编辑页面顶部输入并保存:alias python2='/Library/Frameworks/Python.framework/Versions/2.x/bin/python2.x'alias python3='/Library/Frameworks/Python.framework/Versions/3.x/bin/python3.x'我机子上有Python2.7和Python3.6版本,上面的x请根据情况自行替换。2.3 重启终端(terminal)或者输入:source ~/.bashrc2.4 验证,在终端(terminal)中输入python2即代表是Python2.x版本,输入python3即代表是Python3.x版本。

3. 完成上面的步骤后,应该来说没问题了。接下来就是通过pip 安装 第三方模块。

在这里我说一下我遇到的情况,我是先安装Python 3.6.3, 再安装Python 2.7.14, 在pip3 install xx 是通过的,在在pip2 install xx 就报错了:

$ pip2 install requestsCollecting requestsCould not fetch URL /simple/requests/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skippingCould not find a version that satisfies the requirement requests (from versions: )No matching distribution found for requestsYou are using pip version 9.0.1, however version 10.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' command.

我按照提示更新pip install --upgrade pip,咦~没用:

$ pip install --upgrade pipCould not fetch URL /simple/pip/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skippingRequirement already up-to-date: pip in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packagesYou are using pip version 9.0.1, however version 10.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' command.

后面想想,我pip 都无效,应该选择有效的pip3 进行更新:

$ pip3 install --upgrade pipCollecting pipDownloading /packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)100% |████████████████████████████████| 1.3MB 623kB/s Installing collected packages: pipFound existing installation: pip 9.0.3Uninstalling pip-9.0.3:Successfully uninstalled pip-9.0.3Successfully installed pip-10.0.1cfzxdeiMac:~ cfzx$ pip2 install --upgrade pipCollecting pipUsing cached /packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whlInstalling collected packages: pipFound existing installation: pip 9.0.1Uninstalling pip-9.0.1:Successfully uninstalled pip-9.0.1Successfully installed pip-10.0.1

成功之后我再试试看:

$ pip2 install requestsCollecting requests……Successfully installed certifi-.4.16 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22

文章摘录【/Neo-Wang/p/7028582.html】

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。