我正在使用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变量。我不知道为什么我仍然会收到这个错误。有人可以指出吗? 感谢
答案 0 :(得分: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/"
答案 1 :(得分: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
文件也应具有这些设置,如许多其他网站所述。