Search code examples
pythonpython-2.7cherrypy

ImportError: cannot import name cpg


I have this project that I find on the http://www.ibm.com/developerworks/opensource/library/os-cherrypy/?ca=dgr-lnxw01CherryPy

#!/usr/bin/env python
import cherrypy
from cherrypy import cpg

class Application:
    @cpg.expose
    def hello(self, what='Hello', who='world'):
        return '%s, %s!' % (what, who)
cpg.root = Application()
cpg.server.start()

But I think the site is old and I have the python's version is 2.7.3.

The error is

Traceback (most recent call last):
File "hello4.py", line 3, in <module>
from cherrypy import cpg
ImportError: cannot import name cpg

For install the program 's cherrypy http://sourceforge.net/apps/trac/xenwebmanager/wiki/GettingStarted

what has changed with the new version of python?

How to change for using the project for python 2.7.3?


Solution

  • cherrypy.cpg was removed in 2.1. You need to find some docs more recent than 2005.