How To Install Google App Engine Python3 In Eclipse
Google app engine Python hello world example using Eclipse
In this tutorial, we will show you how to use Eclipse to create a Google App Engine (GAE) Python web project (hello world example), run it locally, and deploy it to Google App Engine account.
Tools used :
- Python 2.7
- Eclipse 3.7 + PyDev plugin
- Google App Engine SDK for Python 1.6.4
P.S Assume Python 2.7 and Eclipse 3.7 are installed.
1. Install PyDev plugin for Eclipse
Use following URL to install PyDev as Eclipse plugin.
http://pydev.org/updates
Figure 1 – In Eclipse , menu, "Help –> Install New Software.." and put above URL. Select "PyDev for Eclipse" option, follow steps, and restart Eclipse once completed.
2. Verify PyDev
After Eclipse is restarted, make sure PyDev's interpreter is pointed to your "python.exe
".
Figure 2 – Eclipse -> Windows –> Preferences, make sure "Interpreter – Python" is configured properly.
3. Google App Engine SDK Python
Download and install Google App Engine SDK for Python.
4. Python Hello World in Eclipse
Following steps to show you how to create a GAE project via Pydev plugin.
Figure 4.1 – Eclipse menu, File -> New -> Other… , PyDev folder, choose "PyDev Google App Engine Project".
Figure 4.2 – Type project name, if the interpreter is not configure yet (in step 2), you can do it now. And select this option – "Create 'src' folder and add it to PYTHONPATH".
Figure 4.3 – Click "Browse" button and point it to the Google App Engine installed directory (in step 3).
Figure 4.4 – Name your application id in GAE, type anything, you can change it later. And choose "Hello Webapp World" template to generate the sample files.
Figure 4.5 – Done, 4 files are generated, Both ".pydevproject
" and ".project
" are Eclipse project files, ignore it.
Review the generated Python's files :
File : helloworld.py – Just output a hello world.
from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, webapp World!') application = webapp.WSGIApplication([('/', MainPage)], debug=True) def main(): run_wsgi_app(application) if __name__ == "__main__": main()
File : app.yaml – GAE need this file to run and deploy your Python project, it's quite self-explanatory, for detail syntax and configuration, visit yaml and app.yaml reference.
application: mkyong-python version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py
5. Run it locally
To run it locally, right click on the helloworld.py
, choose "Run As" –> "Run Configuration", create a new "PyDev Google App Run".
Figure 5.1 – In Main tab -> Main module, manually type the directory path of "dev_appserver.py". "Browse" button is not able to help you, type manually.
Figure 5.2 – In Arguments tab -> Program arguments, put "${project_loc}/src".
Figure 5.3 – Run it. By default, it will deploy to http://localhost:8080.
Figure 5.4 – Done.
5. Deploy to Google App Engine
Register an account on https://appengine.google.com/, and create an application ID for your web application. Review "app.yaml
" again, this web app will be deployed to GAE with application ID "mkyong-python".
File : app.yaml
application: mkyong-python version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py
To deploy to GAE, see following steps :
Figure 5.1 – Create another new "PyDev Google App Run", In Main tab -> Main module, manually type the directory path of "appcfg.py".
Figure 5.2 – In Arguments tab -> Program arguments, put "update ${project_loc}/src".
Figure 5.3 – During deploying process, you need to type your GAE email and password for authentication.
Figure 5.4 – If success, the web app will be deployed to – http://mkyong-python.appspot.com/.
Done.
References
- PyDev Plugin for Eclipse
- Yaml Official Website
- GAE getting start with Python
- Install PyDev for Eclipse
- GAE Java hello world example using Eclipse
Comments
How To Install Google App Engine Python3 In Eclipse
Source: https://mkyong.com/google-app-engine/google-app-engine-python-hello-world-example-using-eclipse/
Posted by: cabreraaltatter.blogspot.com
0 Response to "How To Install Google App Engine Python3 In Eclipse"
Post a Comment