Install CherryPy 3.2 on Ubuntu 11.04 and run it with Python 3.2

Post to Twitter

CherryPy has been a very cool project to me for a long time. Today I’ll show you how you can install it on Ubuntu 11.04 and run it using Python 3.2.


The first step is to ensure you have Python 3.2 installed on Ubuntu 11.04 – for that check out my article here on how to do that.

Now you can go into the Ubuntu Terminal and grab, extract, and install CherryPy:

$ wget http://download.cherrypy.org/cherrypy/3.2.0/CherryPy-3.2.0.tar.gz
$ tar -xvf CherryPy-3.2.0.tar.gz && cd CherryPy-3.2.0/
$ sudo python3.2 setup.py install

To verify that CherryPy installed correctly do this:

$ python3.2 -c "import cherrypy"

If nothing comes back (no errors) then everything is good.

Using the CherryPy tutorial code we can create a file called hello.py and add the following Python code to it:

import cherrypy

class HelloWorld:
    def index(self):
        return "Hello world!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

To run this program with CherryPy simply do this:

$ python3.2 hello.py

Browse to this address: http://localhost:8080/

Control-C will stop the server.

Post to Twitter

This entry was posted in CherryPy, Python, Ubuntu. Bookmark the permalink.

4 Responses to Install CherryPy 3.2 on Ubuntu 11.04 and run it with Python 3.2

  1. mike says:

    Note that CherryPy is installed in the Python Library directory — which is generally at the location /usr/local/lib/python3.2/site-packages/.

    This means that once you install CherryPy successfully (test it!), you can safely delete all the extracted files and the downloaded tar.gz archive.

  2. Ben Rousch says:

    Have you tried using CherryPy with mod_wsgi under Python3?

  3. Chad Lung says:

    @Ben,

    No, I haven’t yet. I’ve been tied up in Java project both at work and at home.

    Chad

  4. kifcaliph says:

    thank you very much

Comments are closed.