Web.py - AttributeError: object 'module' does not have attribute 'application'

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

 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 tutorials):

 import web urls = ( '/','Index', ) class Index: def GET(self): return "Hello,world!" app=web.application(urls,globals()) if __name__=="__main__": app.run( 

PS: version web.py 0.35.

+6
source share
3 answers

You are faced with name conflicts. You have named your batch website and are trying to import the module website.

I guess this is in the 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.

+9
source

This worked in my case: in the app.yaml file , replace

 - url: /.* script: test.application 

for this,

 - url: /.* script: test.app 

This will resolve the name conflict.

+1
source

Following the recommendations from the user above, I included my comment in the response in order to improve its visibility:

If you first started by invoking your web.py file rather than code.py , as in the Python tutorial, you might also have the web.pyc β€œbyte code” file created in the folder where you are encoding. After detecting a name conflict, be sure to web.pyc file as web.pyc .

+1
source

Source: https://habr.com/ru/post/890931/


All Articles