2013-03-20 218 views
0

我有这个项目,我觉得在http://www.ibm.com/developerworks/opensource/library/os-cherrypy/?ca=dgr-lnxw01CherryPy导入错误:无法导入名CPG

#!/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() 

但我认为该网站是旧的,我有python的版本是2.7.3。

的错误是

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

对于安装程序的CherryPy的http://sourceforge.net/apps/trac/xenwebmanager/wiki/GettingStarted

什么与Python的新版本改变了吗?

如何更改使用python 2.7.3的项目?

回答

2

cherrypy.cpg was removed in 2.1。您需要找到比2005年更近的文档。

+1

是我知道这个... – 2013-03-20 12:16:36

+1

如何更改为python 2.7.3? – 2013-03-20 12:22:18

+0

@MirkoCianfarani Python版本无关紧要。至于所需的更改,您是否尝试阅读链接中的升级指南? – wRAR 2013-03-20 12:23:21

相关问题