Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.py - AttributeError: 'module' object has no attribute 'application'

I use web.py write small helloworld site,but when I run python code.py I get an error message:

Traceback (most recent call last):   File "E:\Python25\webpy\web\mysite.py", line 1, in <module>
    import web   File "E:\Python25\webpy\web\web.py", line 4, in <module>
    app = web.application(urls, globals()) AttributeError: 'module' object has no attribute 'application'

Here is my code(paste from web.py's tutorials):

import web

urls = ( '/','Index',
)

class Index:
  def GET(self):
    return "Hello,world!"

app=web.application(urls,globals())

if __name__=="__main__":
  app.run(

P.S:The web.py version is 0.35.

like image 549
Xhinking Avatar asked Jun 20 '11 14:06

Xhinking


1 Answers

You are runing into name collisions. You named your package web, and are trying to import a module web.

I am assuming this is in a package?

\webpy\web\mysite.py

If so when you do import web you are importing your package not the actual web.py. Rename it, or reorder your pythonpath.

like image 77
Nix Avatar answered Nov 03 '22 01:11

Nix