0

我正在使用 python 3.2.2。如果我尝试这样做:

urllib.request.urlopen('https://pypi.python.org/simple/babel')

我收到以下错误消息:

  Traceback (most recent call last):
    File "solver.py", line 93, in <module>
      generateMetadata('babel')
    File "solver.py", line 76, in generateMetadata
      linklist = parseURL(name)
    File "solver.py", line 20, in parseURL
      resp = opener.open(REP_URL+name+'/')
    File "/usr/lib/python3.2/urllib/request.py", line 375, in open
      response = meth(req, response)
    File "/usr/lib/python3.2/urllib/request.py", line 487, in http_response
      'http', request, response, code, msg, hdrs)
    File "/usr/lib/python3.2/urllib/request.py", line 407, in error
      result = self._call_chain(*args)
    File "/usr/lib/python3.2/urllib/request.py", line 347, in _call_chain
      result = func(*args)
    File "/usr/lib/python3.2/urllib/request.py", line 560, in http_error_302
      headers, fp)
  urllib.error.HTTPError: HTTP Error 301: Moved Permanently - Redirection to url '/simple/Babel' is not allowed

搜索后我发现它应该自动处理重定向。

4

1 回答 1

2

看来,Python 版本 3.2.0 到 3.2.2 中存在一个错误。

如果你知道你的程序的用户会使用这个版本,你可以尝试猴子补丁。(如果他们使用的是故障版本之一,则使用 3.2.3 中的修补模块覆盖模块)

有相应的错误报告:http ://bugs.python.org/issue13696

于 2013-03-19T14:46:31.420 回答