4

我正在使用 nltk.download() 下载我需要的软件包。但我收到以下错误。

root@nishant-Inspiron-1545:/home/nishant/Dropbox/DDP/data# python
Python 2.7.3 (default, Apr 10 2013, 05:09:49)  [GCC 4.7.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> import nltk.downloader
>>> nltk.download()
NLTK Downloader
---------------------------------------------------------------------------
    d) Download      l) List      c) Config      h) Help      q) Quit
---------------------------------------------------------------------------
Downloader> d

Download which package (l=list; x=cancel)?
Identifier> l
Packages:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 644, in download
self._interactive_download()
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 964, in _interactive_download
DownloaderShell(self).run()
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 1000, in run
self._simple_interactive_download(args)
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 1019, in _simple_interactive_download
more_prompt=True, skip_installed=True)
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 453, in list
for info in sorted(getattr(self, category)()):
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 475, in packages
self._update_index()
File "/usr/lib/python2.7/dist-packages/nltk/downloader.py", line 814, in _update_index
ElementTree.parse(urllib2.urlopen(self._url)).getroot())
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 407: Proxy Authentication Required

我在 /etc 中检查了我的环境文件,并在那里设置了 http_proxy 变量。我不知道为什么我仍然收到此错误。请问有人可以指出吗?谢谢

4

2 回答 2

5

nltk 已从 googlecode.com 转移,但网络上的大部分资源仍继续提供参考。

从以下位置更新第 370 行的“/usr/lib/python2.7/dist-packages/nltk/downloader.py”文件中的当前数据服务器设置:

DEFAULT_URL = 'http://nltk.googlecode.com/svn/trunk/nltk_data/index.xml'

DEFAULT_URL = "http://nltk.github.com/nltk_data/"
于 2015-01-03T12:59:54.000 回答
0

需要按照其他答案中的说明更改 URL,但另一个问题是代理身份验证。使用export 命令并设置所有代理变量,即http、https、ftp 和socks,就像这样。

export http_proxy='http://username:'password'@202.141.80.80:3128/' 
export https_proxy='https://username:'password'@202.141.80.80:3128/' 

同样ftp_proxy。

export socks_proxy='socks://username:'password'@202.141.80.80:3128/' 

查看变量是否设置使用export -p

密码可能在引号内,也可能不在引号内。该apt.conf文件还应具有这些设置,如许多其他站点中所述。

于 2015-05-28T16:33:38.710 回答