Python的ex_setup.py的urlopen错误[错误11004]的getaddrinfo失

2019-10-20 23:59发布

我只是在Windows 7上安装了Python作为描述http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/install.html 。 林在第3步,并得到以下错误,当我运行蟒蛇ez_setup.py命令。 我去ez_setup.py从这个URL http://peak.telecommunity.com/dist/ez_setup.py

c:\Python27>python ez_setup.py
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-p
y2.7.egg
Traceback (most recent call last):
  File "ez_setup.py", line 278, in <module>
    main(sys.argv[1:])
  File "ez_setup.py", line 210, in main
    egg = download_setuptools(version, delay=0)
  File "ez_setup.py", line 158, in download_setuptools
    src = urllib2.urlopen(url)
  File "c:\Python27\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "c:\Python27\lib\urllib2.py", line 400, in open
    response = self._open(req, data)
  File "c:\Python27\lib\urllib2.py", line 418, in _open
    '_open', req)
  File "c:\Python27\lib\urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "c:\Python27\lib\urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "c:\Python27\lib\urllib2.py", line 1177, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

c:\Python27>

Answer 1:

答案是在上面的评论。

当你使用代理服务器,存在被用来存储代理设置的Windows环境变量。

该变量http_proxy和安全https_proxy

设置此变量的格式是以下

set http_proxy=user:password@proxyaddress:port
set https_proxy=user:password@proxyaddress:port

如果没有密码,然后执行以下操作

set http_proxy=user@proxyaddress:port

因此,一个例子是

set http_proxy=jbrown:jbpass@192.168.0.252:8080


文章来源: Python ex_setup.py urlopen error [Errno 11004] getaddrinfo failed