So yeah, I am still struggling through “Think Python”. In chapter 9 you are supposed to download a document called “word.txt” from here. And then you are supposed to open the darn thing by typing this in the Python Shell (I use IDLE) fin = open(‘words.txt’). But of course when I typed it, I had to get a God darn error!
This was the error IOError: [Errno 2] No such file or directory: ‘words.txt’.
Since I wasn’t satisfied with what I learned from google, I decided to fiddle around myself, a known recipe for disaster But when it hit me what the problem was, the Python Shell was looking for the file in the wrong place, I solved this issue in a minute.
How to check Python Shell’ s current working directory (the directory in which the Python Shell looks for data/programs). Go to File and then select Path Browser
The Path Browser will open
As you can see the path of the current working directory is /home/Roja, but I had the file saved in /home/Roja/thinkpython.
What did I do? I quickly found out I couldn’t move to the /thinkpython directory in the Path Browser. So I copied the file from /home/Roja/thinkpython to /home/Roja. It is not the most elegant solution I’ll admit but it worked and I was able to continue with the book.
Remember, you can always do the cliccie for larger piccie!
(This is what the Python Shell looks like when it can’t find the file
and this when it can