i'm using the PyCharm IDE, and I am trying to import webapp2 from the google app engine SDK. Since the module does not come with python, it doesn't recognize it "No module named webapp2".. I am using the pycharm community version, is there anyway around this? can I import the SDK somehow?
4 Answers
PyCharm Community Edition can be configured to work with Google App Engine python and hence webapp2. You won't get all the advantages of PyCharm Professional Edition such as deployment, but you'll be able to do step by step debugging and get code navigation and auto-completion working.
To enable debugging, edit the PyCharm Run/Debug configuration by setting:
- Script: App Engine's dev_appserver.py
- Script parameters:
--automatic_restart=no --max_module_instances="default:1" . - Working directory: your base project folder (the one which contains the app.yaml file)
PyCharm Community Edition does not have support for Google App Engine.
Reference: PyCharm Editions Comparison
Here's the guide which can help you to install webapp2: Quick start (to use webapp2 outside of App Engine)
Note: webapp2 is just the first step, and you will miss PyCharm integration with Google App Engine. If your project requires other Google App Engine services, consider investment into Professional version of PyCharm.
I'm using PyCharm (webApp2 library) with google app engine and I tried to found the best way for debug by python code, that's what I found:
There is two main options:
PDB (python debugger) - GAE tool for run & debug your code which is default installed in your GAE directory (dev_appserver.py). The tool allows you to run your program from cmd and debug it manually.
"import pdb" to your python code
- use the "pdb.set_trace()" command for put a breakpoint
- use cmd to run the program
cd <google_appengine_dir> python dev_appserver.py <your_project_path>
for ins cd C:\Program Files (x86)\Google\google_appengine
python dev_appserver.py C:\projects\myapp
[pbd syntax][1]
insert pdb to your python code
- The second and the my preferred option is to use the pycharm build-in debugger tool. All you need to do is to use the script dev_appserver.py in the pycharm debug configuration.
If you consider to upgrade to a professional version of PyCharm (or use the 30 days test-license) you can find here a guide for PyCharm showing how to create a google app engine project:
Getting Started with PyCharm as Google App Engine IDE
Before your can create the project you have to download and install the google app engine sdk depending on your platform and which language you want to use: