How to install Python modules

So the other day I was working on Webmaker project on Mozilla Thimble. On the installation part I have a bit of problem where I have to run one of the Python application in order to get the server running.

And the error I get it's below:

bash-3.2$ python app.py  
Traceback (most recent call last):  
  File "app.py", line 2, in <module>
    import bleach
  File "/Users/alihuta2002/htmlsanitizer.org/bleach/__init__.py", line 7, in <module>
    import html5lib
ImportError: No module named html5lib

I'm going to write a tutorial on how to Install Python modules on your Unix, Linux or Mac OS X Machine.

So obviously I have installed Python, but this application needs some library to work with and the one I have problem with was html5lib so I have dig through some google and found a solution to fix this problem by installing this Python's modules manually. First I have to tell you that I don't know if there is an easy to accomplish this or not, but this is how I fixed it.

You must have Python installed in order to use the easy_install command.

So run this command on your terminal

 

sudo easy_install pip

 

Screen Shot 2013-05-15 at 8.43.56 PM

After that you will have pip installed on your system. Where pip it is like a package manager where it will help you download and install Python modules easily.

Now we need to install html5lib by using the following command.

NOTE: If you have problem with other modules simply replace the html5lib with the one you need to install.

sudo pip install html5lib

Screen Shot 2013-05-15 at 8.45.13 PM

Now that the installation of html5lib have been successfully installed on your system.

So the problem fixed and I can run the server with no problem.

I have this tutorial will help some of you, and if you have a better way please do share them with me as well :)