2013-03-20 216 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

相關問題