为什么我不能安装 virtualenv?什么是无匹配分配错误?

Why can't I install virtualenv? what is No matching distribution error?

我是 python 的新手,我想安装 virtualenv 来做点什么。

我尝试使用 pip 和 easy_install 来安装它,但我收到有关分发问题的错误消息。

我的os是MacOS 10.12.6,之前我的系统里安装过pycharm

这是sys.path

['', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']

easy_install

sudo easy_install virtualenv

Searching for virtualenv
Reading https://pypi.python.org/simple/virtualenv/
Download error on https://pypi.python.org/simple/virtualenv/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
Couldn't find index page for 'virtualenv' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
No local packages or download links found for virtualenv
error: Could not find suitable distribution for Requirement.parse('virtualenv')

点子

sudo pip install virtualenv

The directory '/Users/posen/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/posen/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virtualenv
  Could not fetch URL https://pypi.python.org/simple/virtualenv/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
  Could not find a version that satisfies the requirement virtualenv (from versions: )
No matching distribution found for virtualenv

我无法理解发生了什么,有人可以建议我如何解决这个问题吗?

problem 由于 pip 版本较旧而发生。要解决它,您可以使用此命令将 pip 升级到最新版本。

pip install --upgrade virtualenv

解决问题的步骤如下:

  1. 升级画中画pip install --upgrade pip
  2. 升级虚拟环境pip install --upgrade virtualenv