0
votes

I am getting an error while trying to read a file within the code.

File isn't open for reading") PermissionDeniedError: File isn't open for reading

file is located within the trainer folder on the google cloud shell. This is what I have given to read the file with file_io.FileIO('/home/arpit_agrawal/DeepSpeech/trainer/data/‌​spell/words.txt','r+‌​') as f: WORDS = set(words(f.read()))

THIS WAS THE ERROR IN LOG FILES : WORDS = set(words(f.read())) File "/root/.local/lib/python2.7/site-packages/tensorflow/python/‌​lib/io/file_io.py", line 106, in read self._preread_check() File "/root/.local/lib/python2.7/site-packages/tensorflow/python/‌​lib/io/file_io.py", line 70, in _preread_check "File isn't open for reading") PermissionDeniedError: File isn't open for reading

result of ls -la for words.txt

-rwxr-xr-x 1 arpit_agrawal arpit_agrawal 12124743 Apr 11 17:53 words.txt
1
Can you please paste the code you are using to read the file. Is the file located on GCS or the local filesystem? Are you running locally or using the CMLE service?Jeremy Lewi
file is located within the trainer folder on the google cloud shell. This is what I have given to read the file with file_io.FileIO('/home/arpit_agrawal/DeepSpeech/trainer/data/spell/words.txt','r+') as f: WORDS = set(words(f.read()))Appu
THIS WAS THE ERROR IN LOG FILES :<module> WORDS = set(words(f.read())) File "/root/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 106, in read self._preread_check() File "/root/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 70, in _preread_check "File isn't open for reading") PermissionDeniedError: File isn't open for readingAppu
@Appu: At the bottom of your question, there's an "edit" link that is crying out for you to click on it. :-)ruakh
The code looks correct. Does the file exist and what are the permissions? Can you do an ls -la /home/arpit_agrawal/DeepSpeech/trainer/data/‌​spell/words.txt and paste the output into the original question? Are you running inside Cloud Shell?Jeremy Lewi

1 Answers

0
votes

It looks like it is a unicode issue in the code you pasted. Specifically there are non printable unicode characters there. I copied and pasted from the code you wrote and ran the following.

In [2]: 'r+‌​'=='r+'
Out[2]: False

The left one was copied from the original stackoverflow post. I'd suggest deleting that code and retyping it.