HTTP: proxy authentication error for nltk.download ()

I use nltk.download () to download the packages I need. But I get the following error.

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 

I checked the environment file in / etc and the http_proxy variable was set there. I do not know why I am still getting this error. Please can someone point? Thanks

+4
source share
2 answers

nltk has moved from googlecode.com, but still most resources on the network continue to provide a link.

update the current data server in the file "/usr/lib/python2.7/dist-packages/nltk/downloader.py" on line 370 from:

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

to

 DEFAULT_URL = "http://nltk.github.com/nltk_data/" 
+5
source

Changing the url is required as indicated in another answer, but proxy authentication is another problem. Use the export command and set all proxy variables, i.e. http, https, ftp and socks, for example.

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

Similar to ftp_proxy.

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

to see if variables are set, use export -p

The password may or may not be in quotation marks. The apt.conf file apt.conf also have these parameters, as described in many other sites.

0
source

Source: https://habr.com/ru/post/1491605/


All Articles