I was following nltk book chapter 1. I am able to install nltk
(import nltk
) but was not able to download the book corpus by running nltk.download()
. It gave me getattrinfo failed
error. So I started quickly going through commands in chapter without executing those commands, as most example given requires book corpus.
But now I want to try FreqDist
example.
While running FreqDist
, I realized that I have not done from nltk.book import *
. So, I have again tried to install book corpus. Now, I am absolutely exhausted trying out different solutions given in various posts to fix getattrinfo failed
error that occurs while importing nltk data. (I tried setting up corporate proxy, changing nltk downloader source link among many other stuff)
So instead of following route of using nltk downloader, I tried doing possibly something weird. I downloaded zip from https://github.com/nltk/
, extracted and then ran setup.py
inside it.
Now when I run from nltk.book import *
, I get following output:
>>> from nltk.book import *
*** 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 "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\corpus\util.py", line 63, in __load
try: root = nltk.data.find('corpora/%s' % zip_name)
File "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\data.py", line 641, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'corpora/gutenberg.zip/gutenberg/' not found. Please
use the NLTK Downloader to obtain the resource: >>>
nltk.download()
Searched in:
- 'C:\\Users\\593932/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'D:\\path\\Softwares\\python\\WinPython-64bit-3.4.4.4Qt5\\python-3.4.4.amd64\\nltk_data'
- 'D:\\path\\Softwares\\python\\WinPython-64bit-3.4.4.4Qt5\\python-3.4.4.amd64\\lib\\nltk_data'
- 'C:\\Users\\593932\\AppData\\Roaming\\nltk_data'
**********************************************************************
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\book.py", line 20, in <module>
text1 = Text(gutenberg.words('melville-moby_dick.txt'))
File "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\corpus\util.py", line 99, in __getattr__
self.__load()
File "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\corpus\util.py", line 64, in __load
except LookupError: raise e
File "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\corpus\util.py", line 61, in __load
root = nltk.data.find('corpora/%s' % self.__name)
File "D:\path\Softwares\python\WinPython-64bit-3.4.4.4Qt5\python-3.4.4.amd64\lib\site-packages\nltk\data.py", line 641, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'corpora/gutenberg' not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- 'C:\\Users\\593932/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'D:\\path\\Softwares\\python\\WinPython-64bit-3.4.4.4Qt5\\python-3.4.4.amd64\\nltk_data'
- 'D:\\path\\Softwares\\python\\WinPython-64bit-3.4.4.4Qt5\\python-3.4.4.amd64\\lib\\nltk_data'
- 'C:\\Users\\593932\\AppData\\Roaming\\nltk_data'
**********************************************************************
>>>
I manually copy pasted the nltk
folder which also contains book.py
in various folders listed above:
- 'C:\\Users\\593932/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'D:\\path\\Softwares\\python\\WinPython-64bit-3.4.4.4Qt5\\python-3.4.4.amd64\\nltk_data'
- 'D:\\path\\Softwares\\python\\WinPython-64bit-3.4.4.4Qt5\\python-3.4.4.amd64\\lib\\nltk_data'
- 'C:\\Users\\593932\\AppData\\Roaming\\nltk_data'
But no use. How can I get this book stuff imported in my interpreter environment from zip downloaded from github, without requiring to use nltk downloader? Is it even possible?