Pip无法访问网站,全新安装Python 2.7.9

时间:2015-03-25 21:37:51

标签: python pip openpyxl

我刚刚完成了一个新的/干净的Python 2.7.9安装来获取pip(无法通过任何其他方式获得它),现在当我使用它安装一些东西时,我收到了这个错误:

pip install openpyxl
Downloading/unpacking openpyxl
  Cannot fetch index base URL https://pypi.python.org/simple
  Could not find any downloads that satisfy the requirement openpyxl
Cleaning up...
No distributions at all found for openpyxl
Storing debug log for failure in C:\Users\name\pip\pip.log

错误日志看起来很相似,只有很多超时消息没有更多信息:

  Downloading/unpacking openpyxl
  Getting page https://pypi.python.org/simple/openpyxl/
  Could not fetch URL https://pypi.python.org/simple/openpyxl/: timed out
  Will skip URL https://pypi.python.org/simple/openpyxl/ when looking for download links for openpyxl
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: timed out
  Will skip URL https://pypi.python.org/simple/ when looking for download links for openpyxl
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for openpyxl:
  * https://pypi.python.org/simple/openpyxl/
  Getting page https://pypi.python.org/simple/openpyxl/
  Could not fetch URL https://pypi.python.org/simple/openpyxl/: timed out
  Will skip URL https://pypi.python.org/simple/openpyxl/ when looking for download links for openpyxl
  Could not find any downloads that satisfy the requirement openpyxl
Cleaning up...
  Removing temporary dir c:\users\dqa8300\appdata\local\temp\pip_build_DQA8300...
No distributions at all found for openpyxl
Exception information:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python27\lib\site-packages\pip\req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "C:\Python27\lib\site-packages\pip\index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for openpyxl

我假设这是网络的事情,有什么工作吗?

2 个答案:

答案 0 :(得分:2)

这似乎是一个网络问题。

如果您可以在浏览器中打开https://pypi.python.org/simple/openpyxl/,则可能是其他问题。

答案 1 :(得分:1)

您的企业园区内的防火墙似乎已经落后,需要一个代理才能在本地网络外发出HTTP请求。在运行pip之前,您需要在shell中指定代理服务器:

SET HTTPS_PROXY=<proxyHost>:<proxyPort>
SET HTTP_PROXY=<proxyHost>:<proxyPort>

您也可以直接为pip指定代理,但我知道此功能在某个时刻被破坏了:

pip install <package> --proxy=<proxyHost>:<proxyPort>

但是,我们无法确定您的代理信息,您需要这样做。你可能会有运气:

import urllib2
print urllib2.getproxies()