Unable to run simple helloworld in gae (python 2.7)

I am trying to run the official helloworld program in google-appengine 1.6.4 for python 2.7.

It is so frustrating that it cannot run a simple helloworld. I would appreciate any help here.

The error I am encountering is: -

shadyabhi@MBP-archlinux ~/codes/gae $ dev_appserver.py helloworld/ INFO 2012-04-06 23:25:55,030 appengine_rpc.py:160] Server: appengine.google.com INFO 2012-04-06 23:25:55,034 appcfg.py:582] Checking for updates to the SDK. INFO 2012-04-06 23:25:56,709 appcfg.py:616] This SDK release is newer than the advertised release. WARNING 2012-04-06 23:25:56,710 datastore_file_stub.py:513] Could not read datastore data from /tmp/dev_appserver.datastore INFO 2012-04-06 23:25:56,773 dev_appserver_multiprocess.py:647] Running application dev~helloworld on port 8080: http://localhost:8080 INFO 2012-04-06 23:25:56,774 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8080/_ah/admin WARNING 2012-04-06 23:26:00,928 py_zipimport.py:139] Can't open zipfile /usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info: IOError: [Errno 13] file not accessible: '/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info' ERROR 2012-04-06 23:26:01,101 wsgi.py:189] Traceback (most recent call last): File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 187, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler raise ImportError('%s has no attribute %s' % (handler, name)) ImportError: <module 'helloworld' from '/home/shadyabhi/codes/gae/helloworld/helloworld.pyc'> has no attribute app INFO 2012-04-06 23:26:01,110 dev_appserver.py:2884] "GET / HTTP/1.1" 500 - ERROR 2012-04-06 23:26:01,479 wsgi.py:189] Traceback (most recent call last): File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 187, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler raise ImportError('%s has no attribute %s' % (handler, name)) ImportError: <module 'helloworld' from '/home/shadyabhi/codes/gae/helloworld/helloworld.pyc'> has no attribute app INFO 2012-04-06 23:26:01,486 dev_appserver.py:2884] "GET /favicon.ico HTTP/1.1" 500 - 
+6
source share
7 answers

One of the differences between the files you have on github and the official google hellworld tutorial is that your helloworld file does not seem to be named helloworld.py. Would this potentially help?

Also, do you need the PROJECT_DIR variable at the top of helloworld?

If you are trying to get the main tutorial to work, the first thing you need to do is make sure that your project is literally the same as in the Google example.

+4
source

If you use python2.7 libraries, a tutorial error appears

This line is incorrect:

 application = webapp2.WSGIApplication([('/', MainPage)], debug=True) 

The correct line should be:

 app = webapp2.WSGIApplication([('/', MainPage)], debug=True) 

The WSGI handler complains because it searches for an attribute called "application."

+36
source

checking the git repository, I see that helloworld is not a .py file.
rename it to helloworld.py and you should be good to go.

+1
source

This piece of code helped (note that the โ€œapplicationโ€ has been replaced by the โ€œapplicationโ€):

 app = webapp.WSGIApplication( [('/', MainHandler), ('/upload', UploadHandler), ('/serve/([^/]+)?', ServeHandler), ], debug=True) if __name__ == '__main__': run_wsgi_app(app) 
0
source

I got a 500 error after I copied the code directly from Google. None of the above worked.

All I had to do was change the indentation for each line of code (i.e. change the spaces to tabs) and bingo.

It worked for me.

0
source

When using runtime python 2.7 you do not need to use the main function

Remove this

 if __name__ == '__main__': run_wsgi_app(app) 

and just call

 app = webapp.WSGIApplication( [('/', MainHandler), ('/upload', UploadHandler), ('/serve/([^/]+)?', ServeHandler),], debug=True) 
0
source

I am working on the official welcome world in python 2.7 and found the same error in the app.yaml configuration file The last line reads

script: helloworld.application

he should be

script: helloworld.app

0
source

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


All Articles