简体   繁体   English

Ubuntu中的Cherrypy json_out模块错误

[英]Cherrypy json_out module error in Ubuntu

I am trying to get Cherrypy to output json for a project and on my Mac adding the @cherrpy.tools.json_out() decorator is working a treat but on my Ubuntu 13.04 system I get this error. 我试图让Cherrypy为项目输出json,在我的Mac上添加@ cherrpy.tools.json_out()装饰器正在工作,但是在我的Ubuntu 13.04系统上却出现此错误。

Traceback (most recent call last):
  File "cherrypy.py", line 1, in <module>
    import cherrypy
  File "/bla/cherrypy.py", line 4, in <module>
    class Root(object):
  File "/bla/cherrypy.py", line 6, in Root
    @cherrypy.tools.json_out()
AttributeError: 'module' object has no attribute 'tools'

The code above is a direct copy from the bottom of this page. 上面的代码是此页面底部的直接副本。 http://tools.cherrypy.org/wiki/JSON http://tools.cherrypy.org/wiki/JSON

If i enter a python shell then run interactive help on the module I get a similar result. 如果我输入python shell,然后在模块上运行交互式帮助,则会得到类似的结果。

help> cherrypy
problem in cherrypy - <type 'exceptions.AttributeError'>: 'module' object has no attribute 'tools'

I have tried searching but I can't find anyone else having the same issue? 我尝试搜索,但是找不到其他遇到相同问题的人吗? (Maybe I am missing the wood for the trees?) (也许我错过了树木的木头?)

I have tried reinstalling the package through apt and manually from the cherrypy source all against Python 2.7 我尝试通过apt重新安装程序包,并从cherrypy源手动重新安装所有针对python 2.7的程序包

Although I am developing on Mac and Ubuntu I will be deploying on an Ubuntu server so I would like to sort this out sooner rather than later. 尽管我在Mac和Ubuntu上进行开发,但是我将在Ubuntu服务器上进行部署,因此我希望尽快进行分类。

Your help is much appreciated 非常感谢您的帮助

Do you use python-cherrypy from ubuntu package? 您是否从ubuntu包中使用python-cherrypy It's version is 2.3.0 which does not have cherrypy.tools modules. 它的版本是2.3.0,其中没有cherrypy.tools模块。

Install newer version ( sudo pip install -U cherrypy ). 安装较新的版本( sudo pip install -U cherrypy )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM