0

I have installed cherrypy using pip within a virtualenv and run the first tutorial:

import cherrypy


class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello world!"


if __name__ == '__main__':
    cherrypy.quickstart(HelloWorld())

It throws the error:

Traceback (most recent call last):
  File "C:/wc/playground/scripts/cherrypy.py", line 1, in <module>
    import cherrypy
  File "C:\wc\playground\scripts\cherrypy.py", line 4, in <module>
    class HelloWorld(object):
  File "C:\wc\playground\scripts\cherrypy.py", line 5, in HelloWorld
    @cherrypy.expose
AttributeError: module 'cherrypy' has no attribute 'expose'

Anyone have any idea about why?

Barkles
  • 703
  • 9
  • 12
  • Are you calling your script with virtualenv activated? – patito Feb 15 '17 at 23:12
  • Yes, I definitely am! Its strange though: if I open python through cmd and execute each line individually, it works. If its run as a script, this error appears. – Barkles Feb 15 '17 at 23:27

0 Answers0