尝试在Windows机器上使用pip安装virtualenv,但面临以下错误
pip install virtualenv
Collecting virtualenv
Exception:
Traceback (most recent call last): File "c:python27libsite-packagespipbasecommand.py", line 215, in main status = self.run(options, args)
File "c:python27libsite-packagespipcommandsinstall.py", line 324, in run
requirement_set.prepare_files(finder)
File "c:python27libsite-packagespipreqreq_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies))
File "c:python27libsite-packagespipreqreq_set.py", line 620, in _prepare_file session=self.session, hashes=hashes)
File "c:python27libsite-packagespipdownload.py", line 821, in unpack_url hashes=hashes
File "c:python27libsite-packagespipdownload.py", line 659, in unpack_http_url hashes)
File "c:python27libsite-packagespipdownload.py", line 853, in _download_http_url stream=True,
File "c:python27libsite-packagespip_vendorrequestssessions.py", line 488, in get return self.request('GET', url, **kwargs)
File "c:python27libsite-packagespipdownload.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs)
File "c:python27libsite-packagespip_vendorrequestssessions.py", line 475, in request resp = self.send(prep, **send_kwargs)
File "c:python27libsite-packagespip_vendorrequestssessions.py", line 596, in send r = adapter.send(request, **kwargs)
File "c:python27libsite-packagespip_vendorcachecontroladapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw)
File "c:python27libsite-packagespip_vendorrequestsadapters.py", line 497, in send raise SSLError(e, request=request)
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
您是否尝试过使用cmd行作为管理员在下面运行,
pip install virtualenv
Virtualenv 附带一个 pip 副本,该副本被复制到您创建的每个新环境中,因此 virtualenv 是所有需要的。您可以尝试将 virtualenv 作为独立软件包单独安装。对于Windows用户来说,这实际上更容易。有关说明,请参阅 https://virtualenv.pypa.io/en/stable/。
您需要先升级 PIP
python -m pip install --upgrade pip
然后你可以通过管理员访问安装你的包
pip install virtualenv
问题已解决!Python 2.7.13附带的pip存在问题,保存了此文件(https://bootstrap.pypa.io/get-pip.py),然后命令"python get-pip.py"通过升级它解决了问题。由于命令"python -m pip install --upgrade pip"本身给出了与上面提到的相同的错误。谢谢大家!