我正在关注第一章NLTK书 http://www.nltk.org/book/ch01.html#frequency-distributions。它要求我们通过运行来安装图书语料库nltk.dowwnload()
.
我正进入(状态getattrinfo failed
做的时候出错ntlk.download()
。上网查了一下,才知道这和我的代理有关系。
所以我尝试以不同的方式设置代理(尝试http
or https
, %40
or @
在密码中):
nltk.set_proxy('http://proxy.mycompany.com:8080',('123456','password%40123'))
nltk.set_proxy('http://proxy.mycompany.com:8080',('123456','password@123'))
nltk.set_proxy('https://proxy.mycompany.com:8080',('123456','password%40123'))
nltk.set_proxy('https://proxy.mycompany.com:8080',('123456','password@123'))
(我能够成功设置代理pip
并安装nltk
,但不确定我是否犯了错误nltk
proxy)
然后我也尝试了
C:\Users\123456>python -m nltk.downloader all
[nltk_data] Error loading all: <urlopen error [Errno 11004]
[nltk_data] getaddrinfo failed>
Error installing package. Retry? [n/y/e]
接下来我尝试了
>>>nltk.download('book')
但这也给出了同样的错误:
>>> nltk.download('book')
[nltk_data] Error loading book: <urlopen error [Errno 11004]
[nltk_data] getaddrinfo failed>
然后我还尝试按照建议更改服务器索引 urlhere https://stackoverflow.com/a/27764910/1317018,但是没有用。还有预填充索引处于活动状态 https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml(我可以在浏览器中打开它),所以我想我不需要更改服务器索引 url。