简体   繁体   English

在pycharm中使用谷歌应用引擎SDK

[英]using google app engine SDK in pycharm

i'm using the PyCharm IDE, and I am trying to import webapp2 from the google app engine SDK. 我正在使用PyCharm IDE,我正在尝试从谷歌应用引擎SDK导入webapp2。 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? 由于该模块没有附带python,因此它无法识别它“没有名为webapp2的模块”..我正在使用pycharm社区版本,无论如何都在这周围? can I import the SDK somehow? 我可以以某种方式导入SDK吗?

PyCharm Community Edition can be configured to work with Google App Engine python and hence webapp2. 可以将PyCharm Community Edition配置为使用Google App Engine python,从而使用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. 您将无法获得PyCharm Professional Edition的所有优势,例如部署,但您将能够逐步调试并获得代码导航和自动完成工作。

To enable debugging, edit the PyCharm Run/Debug configuration by setting: 要启用调试,请通过设置来编辑PyCharm Run / Debug配置:

  • Script: App Engine's dev_appserver.py 脚本:App Engine的dev_appserver.py
  • Script parameters: --automatic_restart=no --max_module_instances="default:1" . 脚本参数: - --automatic_restart=no --max_module_instances="default:1" .
  • Working directory: your base project folder (the one which contains the app.yaml file) 工作目录:您的基础项目文件夹(包含app.yaml文件的文件夹)

For more detailed instructions, explanations, and how get code completion working in your PyCharm CE project, see this tutorial . 有关更详细的说明,解释以及如何在PyCharm CE项目中完成代码完成,请参阅本教程

PyCharm Community Edition does not have support for Google App Engine. PyCharm Community Edition不支持Google App Engine。

Reference: PyCharm Editions Comparison 参考: PyCharm版本比较

Here's the guide which can help you to install webapp2: Quick start (to use webapp2 outside of App Engine) 以下是可以帮助您安装webapp2的指南: 快速入门(在App Engine之外使用webapp2)

Note: webapp2 is just the first step, and you will miss PyCharm integration with Google App Engine. 注意: webapp2只是第一步,您将错过PyCharm与Google App Engine的集成。 If your project requires other Google App Engine services, consider investment into Professional version of PyCharm. 如果您的项目需要其他Google App Engine服务,请考虑投资专业版的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: 我正在使用带有谷歌应用程序引擎的PyCharm(webApp2库),我试图通过python代码找到调试的最佳方法,这就是我发现的:

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). PDB(python调试器) - 用于运行和调试代码的GAE工具,默认安装在GAE目录(dev_appserver.py)中。 The tool allows you to run your program from cmd and debug it manually. 该工具允许您从cmd运行程序并手动调试它。

  • "import pdb" to your python code “导入pdb”到你的python代码

  • use the "pdb.set_trace()" command for put a breakpoint 使用“pdb.set_trace()”命令放置断点
  • use cmd to run the program cd <google_appengine_dir> python dev_appserver.py <your_project_path> 使用cmd运行程序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 for ins cd C:\\Program Files (x86)\\Google\\google_appengine python dev_appserver.py C:\\projects\\myapp

[pbd syntax][1] [pbd语法] [1]

insert pdb to your python code 将pdb插入python代码

  1. The second and the my preferred option is to use the pycharm build-in debugger tool. 第二个和我首选的选项是使用pycharm内置调试工具。 All you need to do is to use the script dev_appserver.py in the pycharm debug configuration. 您需要做的就是在pycharm调试配置中使用脚本dev_appserver.py。

Configure python GAE debugging 配置python GAE调试

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: 如果您考虑升级到PyCharm的专业版(或使用30天测试许可证),您可以在这里找到PyCharm指南,展示如何创建谷歌应用程序引擎项目:

Getting Started with PyCharm as Google App Engine IDE PyCharm入门作为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: 在您创建项目之前,您必须下载并安装Google App引擎sdk,具体取决于您的平台以及您要使用的语言:

Download the Google App Engine SDK 下载Google App Engine SDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM