【问题标题】:Download error on http://pypi.python.org/simple/PACKAGE: [Errno -5] No address associated with hostname - Python Library HTTPLib Issue?http://pypi.python.org/simple/PACKAGE 上的下载错误:[Errno -5] 没有与主机名关联的地址 - Python 库 HTTPLib 问题?
【发布时间】:2015-01-03 18:43:52
【问题描述】:

我正在尝试通过 pip 下载一些包(目前是 google API) - 但我收到了以下响应:

pi@raspberrypi ~ $ sudo easy_install google-api-python-client
Searching for google-api-python-client
Best match: google-api-python-client 1.3.1
Processing google_api_python_client-1.3.1-py2.7.egg
google-api-python-client 1.3.1 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/google_api_python_client-1.3.1-py2.7.egg
Processing dependencies for google-api-python-client
Searching for uritemplate>=0.6
Reading http://pypi.python.org/simple/uritemplate/
Download error on http://pypi.python.org/simple/uritemplate/: [Errno -5] No address associated with hostname -- Some packages may not be found!
Reading http://pypi.python.org/simple/uritemplate/
Download error on http://pypi.python.org/simple/uritemplate/: [Errno -5] No address associated with hostname -- Some packages may not be found!
Couldn't find index page for 'uritemplate' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Download error on http://pypi.python.org/simple/: [Errno -5] No address associated with hostname -- Some packages may not be found!
No local packages or download links found for uritemplate>=0.6
error: Could not find suitable distribution for Requirement.parse('uritemplate>=0.6')

现在,我想我会在这里而不是在 RPi.SE 上提问,因为这似乎已经在这里被问过并回答了好几次了。现在,通常情况下,这将构成 再次询问 - 但这些解决方案都没有帮助。

看过

仅举几例。

其中一些解决方案提到了导致此错误的代理问题 - 但是,这不是我的问题,因为我没有代理并且我的 $http_proxy 为空:

pi@raspberrypi ~ $ echo $http_proxy

pi@raspberrypi ~ $ 

提到的另一个问题是缺少正确的 SSL 版本,给出的解决方案是安装 pip 1.2.1……现在这似乎有点过时了。我是否需要安装特定版本的 OpenSSL/pip?

确实安装了 pip 1.2.1,我之前有 1.1.1(来自 Raspbian 存储库的包)但得到了同样的错误。

知道是什么原因造成的吗?

编辑:这是 HTTPLib 错误吗?

我认为这是在我的 Raspberry Pi 上安装 Python 的问题,因为我在使用 httplib python 库的其他一些代码中遇到了相同的错误 ([Errno -5] No address associated with hostname)。 httplib 库中的问题肯定会解释这个问题。

注意,curlwgetlynx 都可以正常工作。

【问题讨论】:

  • 但是您可以从浏览器访问https://pypi.python.org/simple/uritemplate/,使用wget 或类似的东西?
  • @cel 正确。我可以通过wget 和我桌面上的 Firefox 访问它。
  • 抱歉,wget 在你的 rpi 的外壳中,对吗?
  • @cel 正确,wget 在我的 Pi 上工作。
  • @cel 我认为这实际上是 httplib 的一个问题,因为我自己的一些使用 httplib 的代码也出现了完全相同的错误 - 错误 5

标签: python python-2.7 pip httplib


【解决方案1】:

我根据this post on the Raspberry Pi Forums 解决了这个问题。

我必须先编辑/usr/lib/python2.7/socket.py 文件中的create_connection() 函数才能将主机名解析为IP:

原始代码:

def create_connection(.....)

host, port = address
err = None
for res in getaddrinfo(host, port, 0, SOCK_STREAM):

编辑代码:

def create_connection(.....)

host, port = address
err = None
hostip = gethostbyname(host)
for res in getaddrinfo(hostip, port, 0, SOCK_STREAM):

【讨论】:

  • +1,谢谢!它解决了我的问题!我认为这应该进入标准 /usr/lib/python2.7/socket.py 来修复这个错误
猜你喜欢
  • 2023-03-26
  • 2020-11-29
  • 1970-01-01
  • 2022-10-04
  • 2021-01-20
  • 2021-10-08
  • 2023-03-05
  • 2021-04-19
  • 1970-01-01
相关资源
最近更新 更多