La Boina Roja

Linux, the struggles are real!

Leave a comment

Struggling through chapter 9, Reading Word Lists

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 photo piangry.gif!

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 photo loveit.gif  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  photo puh2.gif 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



How to install Swampy using Easy Install in Fedora

If you are going through “Think Python” you’ ll see that in chapter 4, you will be asked to install Swampy. What disappoints me about this is, there are no clear instructions on how to get the darn thing installed Photobucket Making this book, not really aimed at novices imo,  other than that it is a great book.

Before you do anything, I suggest to check which version of python you have running right now. You do this by opening the terminal and simply typing “python” without the quotation marks. It looks like this.


As you can see I am running python 2.7.3, the ”3″ isn’t important for this tutorial.

Now, we are going to get “Easy Install” , go to this site and scroll all the way down until you see this.


Click and download the version of setup tools which correspondents with the current version of python you have ( in my case it is setuptools-0.6c11-py2.7.egg). Make sure to download it into your downloads folder.

Open terminal  (if you are still in python, press “ctrl” and “d” at the same time to exit) and move to the downloads folder. You do this by typing “cd ~/Downloads”,  I also suggest logging in as root after you are in the downloads folder.


After you have logged in as root, you have to run the file you downloaded as a script, you do this by typing ” sh setuptools-0.6c11-py2.7.egg” .


After the installation is done, return to your home directory by typing “cd ~”. Now you are ready to install Swampy, finally! Type in terminal “easy_install Swampy”.


And you are done!

(If you want to be sure whether Swampy is installed or not, just type ” import swampy.TurtleWorld” in python. If you don’t get a message it’s installed, it will look like this:

check swampy

If it is not installed, you’ ll get some scary message Photobucket)

Remember you can always do the cliccie for a larger piccie!