Я пытался загрузить пакеты из nltk после того, как импортировал nltk в Python. Он выдает следующую ошибку:
Затем я попытался nltk.set_proxy
, потому что я использую прокси в Китае. Однако используемые мной прокси не имеют имени пользователя и пароля. Поэтому мой код выглядит как nltk.set_proxy('http://proxy.example.com:3128')
Когда я снова запустил nltk.download()
, появляются сообщения об ошибках:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
nltk.download()
File "/Users/zbao/Library/Python/3.8/lib/python/site-packages/nltk/downloader.py", line 773, in download
self._interactive_download()
File "/Users/zbao/Library/Python/3.8/lib/python/site-packages/nltk/downloader.py", line 1123, in _interactive_download
DownloaderGUI(self).mainloop()
File "/Users/zbao/Library/Python/3.8/lib/python/site-packages/nltk/downloader.py", line 1423, in __init__
self._fill_table()
File "/Users/zbao/Library/Python/3.8/lib/python/site-packages/nltk/downloader.py", line 1755, in _fill_table
items = self._ds.collections()
File "/Users/zbao/Library/Python/3.8/lib/python/site-packages/nltk/downloader.py", line 600, in collections
self._update_index()
File "/Users/zbao/Library/Python/3.8/lib/python/site-packages/nltk/downloader.py", line 962, in _update_index
ElementTree.parse(urlopen(self._url)).getroot()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1362, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1319, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1392, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 920, in connect
self._tunnel()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 894, in _tunnel
(version, code, message) = response._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 285, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: <html
Кто-нибудь знает, в чем может быть проблема? Заранее спасибо!