我用的是anaconda,自带nltk,但是没有扩展语料库,需要通过nltk.download()进行下载。
运行后,直接提示WinError 10060(也可能是其他错误信息),然后下载器直接未响应。
网上各种解决方案,看的人头晕,表达都是一个意思,离线下载安装。
还给了两个地址,分别是:
地址1: https://github.com/nltk/nltk_data # 有时候打不开,需要架梯子,只需下载packages文件夹 地址2: http://www.nltk.org/nltk_data/ # 有时候打不开,需要架梯子
在dos下先进入python,然后输入import nltk.book,出现如下报错:
>>>import nltk.book
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
Traceback (most recent call last):
File "g:Anaconda3libsite-packagesnltkcorpusutil.py", line 83, in __load
root = nltk.data.find("{}/{}".format(self.subdir, zip_name))
File "g:Anaconda3libsite-packagesnltkdata.py", line 583, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource [93mgutenberg[0m not found.
Please use the NLTK Downloader to obtain the resource:
[31m>>> import nltk
>>> nltk.download('gutenberg')
[0m
For more information see: https://www.nltk.org/data.html
Attempted to load [93mcorpora/gutenberg.zip/gutenberg/[0m
Searched in:
- 'C:\Users\LayJeme/nltk_data'
- 'g:\Anaconda3\nltk_data'
- 'g:\Anaconda3\share\nltk_data'
- 'g:\Anaconda3\lib\nltk_data'
- 'C:\Users\LayJeme\AppData\Roaming\nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
只需注意该报错的文件路径(随便选一个后续存放离线包用):
Searched in:
- 'C:\Users\LayJeme/nltk_data'
- 'g:\Anaconda3\nltk_data'
- 'g:\Anaconda3\share\nltk_data'
- 'g:\Anaconda3\lib\nltk_data'
- 'C:\Users\LayJeme\AppData\Roaming\nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
注:安装成功后,再输入import nltk.book会出现类似如下提示:
>>> import nltk.book *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent9 Type the name of the text or sentence to view it. Type: 'texts()' or 'sents()' to list the materials. text1: Moby Dick by Herman Melville 1851 text2: Sense and Sensibility by Jane Austen 1811 text3: The Book of Genesis text4: Inaugural Address Corpus text5: Chat Corpus text6: Monty Python and the Holy Grail text7: Wall Street Journal text8: Personals Corpus text9: The Man Who Was Thursday by G . K . Chesterton 1908
记住报错路径,这个是后续语料库存放的地方,这么多路径,你随便选一个即可(我是直接放到anaconda的lib中,和其他的库都放在一起)。
————————————
发牢骚(跳过吧):
刚接触nltk这个东西,安装语料库这东西越简单越好,搞个几小时,结果下过来的还不是自己需要的,人都裂开。地址1和地址2动不动就该页无法打开。地址1的整包下载,我等了5分钟,已下载显示几百M,但进度条一直是0%都不带跳的,直接关闭。最后用梯子解决问题。
————————————
解决思路:
思路1、用nltk.download()下载器自动下载
思路2、手动离线下载
————————————
思路1动手操作:
开局架一部梯子,dos下输入
>>>python >>>import nltk >>>nltk.download()
问题解决,哈哈
————————————
思路2动手操作:
开局架一部梯子,再去将地址1的【packages】文件夹中的所有文件下载下来(地址2里的东西似乎更多更全),放到上面报错路径中的任一文件夹下(例如:g:Anaconda3libnltk_data)。



