W2D5 Tutorial 1 & Tutorial 3: Error in book
spirosChv opened this issue · 1 comments
spirosChv commented
Error because of the manual nltk download. The code is running on colab with no errors.
- Tutorial 1: Interactive Demo 1.1 & 1.2:
LookupError
. Seems that book does not take into account theNLTK_DATA
environment variable.
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/util.py in __load(self)
83 try:
---> 84 root = nltk.data.find(f"{self.subdir}/{zip_name}")
85 except LookupError:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/data.py in find(resource_name, paths)
582 resource_not_found = f"\n{sep}\n{msg}\n{sep}\n"
--> 583 raise LookupError(resource_not_found)
584
LookupError:
**********************************************************************
Resource omw-1.4 not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('omw-1.4')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/omw-1.4.zip/omw-1.4/
Searched in:
- 'nltk_data/'
- '/home/runner/nltk_data'
- '/opt/hostedtoolcache/Python/3.7.12/x64/nltk_data'
- '/opt/hostedtoolcache/Python/3.7.12/x64/share/nltk_data'
- '/opt/hostedtoolcache/Python/3.7.12/x64/lib/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
**********************************************************************
During handling of the above exception, another exception occurred:
LookupError Traceback (most recent call last)
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/ipywidgets/widgets/interaction.py in observer(change)
78 with out:
79 clear_output(wait=True)
---> 80 f(**kwargs)
81 show_inline_matplotlib_plots()
82 for k,w in controls.items():
/tmp/ipykernel_75209/2863717633.py in sample_from_biggan(category, z_magnitude)
7 unit_vector = np.ones((1, 128))/np.sqrt(128)
8 z = z_magnitude * unit_vector
----> 9 y = one_hot_from_names(category, batch_size=1)
10
11 z = torch.from_numpy(z)
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/pytorch_pretrained_biggan/utils.py in one_hot_from_names(class_name_or_list, batch_size)
196 class_name = class_name.replace(" ", "_")
197
--> 198 original_synsets = wn.synsets(class_name)
199 original_synsets = list(filter(lambda s: s.pos() == 'n', original_synsets)) # keep only names
200 if not original_synsets:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/util.py in __getattr__(self, attr)
119 raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
120
--> 121 self.__load()
122 # This looks circular, but its not, since __load() changes our
123 # __class__ to something new:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/util.py in __load(self)
87
88 # Load the corpus.
---> 89 corpus = self.__reader_cls(root, *self.__args, **self.__kwargs)
90
91 # This is where the magic happens! Transform ourselves into
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/reader/wordnet.py in __init__(self, root, omw_reader)
1174 )
1175 else:
-> 1176 self.provenances = self.omw_prov()
1177
1178 # A cache to store the wordnet data of multiple languages
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/reader/wordnet.py in omw_prov(self)
1283 provdict = {}
1284 provdict["eng"] = ""
-> 1285 fileids = self._omw_reader.fileids()
1286 for fileid in fileids:
1287 prov, langfile = os.path.split(fileid)
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/util.py in __getattr__(self, attr)
119 raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
120
--> 121 self.__load()
122 # This looks circular, but its not, since __load() changes our
123 # __class__ to something new:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/util.py in __load(self)
84 root = nltk.data.find(f"{self.subdir}/{zip_name}")
85 except LookupError:
---> 86 raise e
87
88 # Load the corpus.
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/corpus/util.py in __load(self)
79 else:
80 try:
---> 81 root = nltk.data.find(f"{self.subdir}/{self.__name}")
82 except LookupError as e:
83 try:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/nltk/data.py in find(resource_name, paths)
581 sep = "*" * 70
582 resource_not_found = f"\n{sep}\n{msg}\n{sep}\n"
--> 583 raise LookupError(resource_not_found)
584
585
LookupError:
**********************************************************************
Resource omw-1.4 not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('omw-1.4')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/omw-1.4
Searched in:
- 'nltk_data/'
- '/home/runner/nltk_data'
- '/opt/hostedtoolcache/Python/3.7.12/x64/nltk_data'
- '/opt/hostedtoolcache/Python/3.7.12/x64/share/nltk_data'
- '/opt/hostedtoolcache/Python/3.7.12/x64/lib/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
**********************************************************************
- Tutorial 3: Download wordnet dataset:
PermissionError
. Set the environment variableNLTK_DATA
. Take a look here, in "Manual Installation" subsection.
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
/tmp/ipykernel_76242/1588152815.py in <module>
14
15 with zipfile.ZipFile(fname, 'r') as zip_ref:
---> 16 zip_ref.extractall('/usr/local/lib/nltk_data/corpora')
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/zipfile.py in extractall(self, path, members, pwd)
1634
1635 for zipinfo in members:
-> 1636 self._extract_member(zipinfo, path, pwd)
1637
1638 @classmethod
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/zipfile.py in _extract_member(self, member, targetpath, pwd)
1680 upperdirs = os.path.dirname(targetpath)
1681 if upperdirs and not os.path.exists(upperdirs):
-> 1682 os.makedirs(upperdirs)
1683
1684 if member.is_dir():
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
211 if head and tail and not path.exists(head):
212 try:
--> 213 makedirs(head, exist_ok=exist_ok)
214 except FileExistsError:
215 # Defeats race condition when another thread created the path
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
221 return
222 try:
--> 223 mkdir(name, mode)
224 except OSError:
225 # Cannot rely on checking for EEXIST, since the operating system
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/nltk_data'