Giveme5W1H icon indicating copy to clipboard operation
Giveme5W1H copied to clipboard

FileNotFoundError: While running giveme5w1h-rest example.

Open abhimanyuNitSri opened this issue 7 years ago • 14 comments

abhimanyuNitSri avatar Jan 24 '19 11:01 abhimanyuNitSri

To Reproduce :

$ giveme5w1h-corenlp #starting corenlp

copy the example code from README file of the reposetory under the title "Use within your own code (as a library)"

from Giveme5W1H.extractor.document import Document
from Giveme5W1H.extractor.extractor import MasterExtractor

extractor = MasterExtractor()
doc = Document.from_text(text, date_publish)
# or: doc = Document(title, lead, text, date_publish) 
doc = extractor.parse(doc)

top_who_answer = doc.get_top_answer('who').get_parts_as_text()
print(top_who_answer)

input data such as text, date_publish were taken from https://github.com/fhamborg/Giveme5W1H/blob/master/Giveme5W1H/examples/extracting/parse_documents.py

Now run the python file containing the above code (I used jupyter notebook)

ERROR:

Exception in thread Thread-10:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/site-packages/Giveme5W1H/extractor/extractor.py", line 20, in run
    extractor.process(document)
  File "/usr/local/lib/python3.6/site-packages/Giveme5W1H/extractor/extractors/abs_extractor.py", line 40, in process
    self._extract_candidates(document)
  File "/usr/local/lib/python3.6/site-packages/Giveme5W1H/extractor/extractors/environment_extractor.py", line 147, in _extract_candidates
    self._cache_nominatim.cache(location_string, location)
  File "/usr/local/lib/python3.6/site-packages/Giveme5W1H/extractor/tools/key_value_cache.py", line 58, in cache
    self.persist()
  File "/usr/local/lib/python3.6/site-packages/Giveme5W1H/extractor/tools/key_value_cache.py", line 43, in persist
    with open(self._cache_path, 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/Giveme5W1H/examples/caches/Nominatim.prickle'

OS : MacOs 10.14: Python Version : 3.6 Giveme5W1H : 1.0.13 Stanford CoreNLP :stanford-corenlp-full-2018-10-05

abhimanyuNitSri avatar Jan 24 '19 11:01 abhimanyuNitSri

I was able to run the code by copping the caches folder from the repository Giveme5W1H/examples to my local package folder. I also changed the name of the file inside the caches folder by removing the first "_" character.

abhimanyuNitSri avatar Jan 24 '19 12:01 abhimanyuNitSri

I was able to run the code by copping the caches folder from the repository Giveme5W1H.examples to my local package folder. I also changed the name of the file inside the caches folder by removing the first "_" character.

I had the same issue and fixed it the same way you did.

pfmonville avatar Jan 28 '19 16:01 pfmonville

it seems that when using anaconda or jupyter notebook there are issue with file access (also see #29 )

fhamborg avatar Jan 29 '19 10:01 fhamborg

If wget is not pre installed in macOS it cause problem while installing.

abhimanyuNitSri avatar Jan 29 '19 10:01 abhimanyuNitSri

no, the issue at hand is that Giveme5W1H is about to create the file Nominatim.prickle but can't, and hence has no writing permission at that location (/usr/local/lib/python3.6/site-packages/Giveme5W1H/examples/caches/). which is because everything under /usr can only be accessed with writing permission by root but on a regular macOS installation not by a regular user.

fhamborg avatar Jan 29 '19 10:01 fhamborg

@abhimanyuNitSri how exactly did you install Giveme5W1H?

fhamborg avatar Jan 29 '19 10:01 fhamborg

@abhimanyuNitSri how exactly did you install Giveme5W1H?

  1. I manually installed wget
  2. Follow the installing instruction from README file
  3. copied the caches folder from the repository Giveme5W1H/examples to my local package folder.
  4. changed the name of the file inside the caches folder by removing the first "_" character.

If someone have attempted installing before and failed then this might not work as few files are created while installing and are not removed when uninstalling Giveme5W1H. And those previously create file create problem while reinstalling

So for that problem user have to manual delete folders(which where created while initial installing process : "Giveme5W1H" and "giveme5w1h-1.0.13.dist-info") from there /usr/local/lib/python3.6/site-packages/ and then repeat the above steps.

abhimanyuNitSri avatar Jan 29 '19 10:01 abhimanyuNitSri

@abhimanyuNitSri how exactly did you install Giveme5W1H? @fhamborg Sir, I want to work and contribute to open source libraries so please let me know, if I can be of some help to you.

abhimanyuNitSri avatar Jan 29 '19 10:01 abhimanyuNitSri

I had the same problem, installing via pypi. Copying in the caches dir by hand fixed it for me as well.

rahulbot avatar Jan 30 '19 17:01 rahulbot

I had the same problem, installing via pypi. Copying in the caches dir by hand fixed it for me as well.

which operating system are you using.

abhimanyuNitSri avatar Feb 04 '19 11:02 abhimanyuNitSri

I'm using macOS 10.14.2. Python3 installed with pyenv. Giveme5W1H installed with PyPi.

rahulbot avatar Feb 04 '19 13:02 rahulbot

I was able to run the code by copping the caches folder from the repository Giveme5W1H/examples to my local package folder. I also changed the name of the file inside the caches folder by removing the first "_" character.

Same issue. Installed using pip. And fixed it the same way you did.

anarkia7115 avatar Mar 29 '19 10:03 anarkia7115

Same issue here. Ubuntu16, python3.7.

ogencoglu avatar May 20 '20 21:05 ogencoglu