Yesterday i got to know a new friend called CherryPy, a lovely sweet lady? No, it’s a “minimalist Python Web Framework”. Someone replied to my forum topic and he explained quite a lot about web application.

CherryPy seems to be a good alternative to web2py although she is older.
1. So, let’s start off by installing CherryPy in our RaspberryPi by downloading the tar.gz file from here.

UPDATE: can just install using sudo pip install CherryPy

2. Save it in your home/pi directory and open up the LXTerminal.

3. Type:
tar -xzvf CherryPy-3.2.2.tar.gz

4. Rename the file to CherryPy for ease of access

5. Then go to the directory created by the file extraction
cd CherryPy

6. Type: (user has to be root)
sudo python install

7. Run the first sample website by going to cherry/tutorial directory and type “python”
cd cherrypy/tutorial

8. Open your browser (Midori or iceweasel or something else on R-Pi) and type http://localhost:8080 or at the address bar.

There you go, Hello World!🙂

To stop the server, press CTRL+Z. CTRL+C.

** create a new “shutdown” function using “cherry.engine.exit()” and display it as a link on the web app – when clicking that shutdown link, the server will shutdown and the port will be freed.😉

Now i will download the file from the forum and see what he has got for me!

1. Go back to the home directory (where you have saved the zip file)
2. Then create a new folder named mobile_website (or something else of your choice)
3. Move the extracted files into the folder.
4. Go to that folder direcotry in terminal, type:
(it is also possible to edit the file directly using IDLE or other editors)
5. Add in #!/usr/bin/python at the top of the page
6. Edit the tutorial.conf
nano tutorial.conf

Change tools.staticdir.root =”/home/pi/mobile_website”
6. Run python to start the server or double click on the
(Ok, it doesn’t work on my R-Pi)
ChannelFailures: IOError (“Port 80 not free on ‘’”)

Stuck and waiting for someone to help me in the forum.😦


  1. You need to be root to run under port 1024 (i.e. port 80 is below 1024). If you change the port number in the cherrypy server config to a higher port number you should be good (and browse to that port so say http://ipofserver:8080 – if you pick 8080).

    The code seems not to be using your tutorial.conf, but rather some config from inline in the code or some other config file in the tarball.

    1. thank you for your comment :))
      are port 80 and 8080 my only two choices? and how do i see if i’m using tutorial.conf? i’m not too familiar with this as i’m just following some tutorials here and there…

      1. Glad to help. I have used CherryPy before for a couple of projects and they were fun. To answer your question, you will have to look at the configuration in the file you run to see if there is a cherrypy.config inside the file, or if it gets loaded from another file:

        In the example on that page:
        ‘server.socket_port’: 80,

        Specifies port 80, but you can pick another one, probably one that is not in use (if you run a web server locally, you won’t be able to pick 80). If you are not running as root, 8080 is a good pick. You just want to avoid ports that might be in use by other servers running on your computer.

        If the config is loaded from a file, you will see something like this:

        Where the my_file.ini is the config file that will have the ini file syntax (= instead of the colon):

        server.socket_port = 8080

        You can mix and match the configuration from a python dictionary in the file that runs the server part, and / or read in configuration from an ini file.

        Good luck. Once you find what is being used to set the port, you can change it to what works on your computer, but pick a port higher than 1024 if you don’t run the python program as root.

    2. hello! thanks for the reply :)) i’ve changed my port number to 8020 and now i can view the web page! but just a question here: i have checked the list of TCP on wikipedia… but how do i know which port can i use freely? 8020 was suggested by a friend in the forum so i followed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s