http://pypi.python.org/simple/PACKAGE上的下载错误:[Errno-5]没有与主机名关联的地址-python库HTTPLib问题?

2024-06-01 20:57:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图通过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_代理为空:

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的一个问题,因为我在使用Python库的其他一些代码中得到了相同的错误([Errno -5] No address associated with hostname)。httplib库中的一个问题肯定会解释这个问题。

注意,curlwget,和lynx都工作得很好。


Tags: pipnoorgpypiclientapihttpfor
1条回答
网友
1楼 · 发布于 2024-06-01 20:57:49

我根据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):

相关问题 更多 >