{"id":530,"date":"2017-12-31T13:39:25","date_gmt":"2017-12-31T04:39:25","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2017\/12\/31\/google_app_engine_flask_vs_code\/"},"modified":"2017-12-31T13:39:25","modified_gmt":"2017-12-31T04:39:25","slug":"google_app_engine_flask_vs_code","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2017\/12\/31\/google_app_engine_flask_vs_code\/","title":{"rendered":"Google App Engine \u306e Flask \u30b5\u30f3\u30d7\u30eb\u3092 VS Code \u304b\u3089\u5b9f\u884c\u30fb\u30c7\u30d0\u30c3\u30b0\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/www.amazon.co.jp\/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AEGoogle-Cloud-Platform%E5%85%A5%E9%96%80-%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9%E3%81%AE%E5%85%A8%E4%BD%93%E5%83%8F%E3%81%8B%E3%82%89%E3%82%AF%E3%83%A9%E3%82%A6%E3%83%89%E3%83%8D%E3%82%A4%E3%83%86%E3%82%A3%E3%83%96%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E6%A7%8B%E7%AF%89%E3%81%BE%E3%81%A7-%E9%98%BF%E4%BD%90\/dp\/4798137146\/ref=as_li_ss_il?s=books&amp;ie=UTF8&amp;qid=1514695045&amp;sr=1-2&amp;keywords=Google+App+Engine&amp;&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=a8348fb571b3f10f1975608f92139758\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4798137146&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=4798137146\" border=\"0\"><\/p>\n<p>\u57fa\u672c\u7684\u306b\u3001<a title=\"https:\/\/cloud.google.com\/appengine\/docs\/standard\/python\/getting-started\/python-standard-env\" href=\"https:\/\/cloud.google.com\/appengine\/docs\/standard\/python\/getting-started\/python-standard-env\">https:\/\/cloud.google.com\/appengine\/docs\/standard\/python\/getting-started\/python-standard-env<\/a> \u3092\u5b9f\u73fe\u3059\u308b\u3002<\/p>\n<p>\u30b5\u30f3\u30d7\u30eb\u3092\u3001\u4ee5\u4e0b\u304b\u3089\u5165\u624b<\/p>\n<pre class=\"prettyprint linenums\">git clone https:\/\/github.com\/GoogleCloudPlatform\/python-docs-samples<\/pre>\n<p>\u5165\u624b\u5f8c\u3001\/appengine\\standard\\flask\\tutorial \u306bFlask\u306e\u30b5\u30f3\u30d7\u30eb\u304c\u3042\u308b\u3002<\/p>\n<p>VisualStudio Code\u3067\u3001\u30c7\u30d0\u30c3\u30ac\u3092\u4f7f\u7528\u3057\u305f\u3044\u306e\u3067\u3001\u82e5\u5e72\u8abf\u6574\u3059\u308b\u3002<\/p>\n<h2>1.\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<h3>1.1 \u5b9f\u884cPython\u306e\u8a2d\u5b9a<\/h3>\n<p><u><font color=\"#274a78\">\u304c\u3001\u3001<\/font><\/u><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2017\/09\/27\/windows10python3xpython27google_cloud_sdk\">Python3.6\u30012.7 \u74b0\u5883\u304c\u6df7\u5728\u3057\u3066\u3044\u308b<\/a>\u305f\u3081\u3001pip \u2013V \u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001Python3.6\u306e pip \u304c\u8d77\u52d5\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u3068\u308a\u3042\u3048\u305a\u3001Python2.7 \u306epip\u304c\u8d77\u52d5\u3059\u308b\u3088\u3046\u306b\u74b0\u5883\u5909\u6570(PATH)\u3092\u5909\u66f4\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\"> \uff05PYTHON_HOME%\\Scripts\r\n \uff05PYTHON_HOME%<\/pre>\n<p>PYTHON_HOME = C:\\Programs\\Python27-32&nbsp; \u306a\u3069\u3001Python2.7\u3078\u306e\u30d1\u30b9\u3092\u6307\u5b9a<\/p>\n<blockquote>\n<p>\u5f53\u521d\u3001\u4eee\u60f3\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u305f\u304c\u3001\u4e0a\u8a18\u306e\u624b\u9806\u306b\u5f93\u3046\u3068\u3001pip\u306b\u3088\u308a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5148\u306f\u3001\u4f5c\u696d\u30d5\u30a9\u30eb\u30c0 lib \u914d\u4e0b\u3068\u306a\u308b\u305f\u3081\u3001\u4eee\u60f3\u74b0\u5883\u306f\u4e0d\u8981\u3002<\/p>\n<p>\u307e\u305f\u3001VS Code\u304b\u3089\u3001\u30c0\u30a4\u30ec\u30af\u30c8\u306bPython\u3092\u8d77\u52d5\u3057\u306a\u3044\u305f\u3081\u3001VS Code \u306e python.pythonPath \u8a2d\u5b9a\u3067\u306f\u5bfe\u5fdc\u3067\u304d\u306a\u3044\u3002<\/p>\n<\/blockquote>\n<h3>1.2 \u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\u4e0a\u8a18\u3067\u5165\u624b\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306e\u3001\/appengine\\standard\\flask\\tutorial \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089\u4ee5\u4e0b\u3092\u5b9f\u884c<\/p>\n<blockquote>\n<p>-t lib \u30d5\u30e9\u30b0\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u306f \u4f5c\u696d\u30d5\u30a9\u30eb\u30c0\u4ee5\u4e0b\u306elib \u30d5\u30a9\u30eb\u30c0\u3078\u30b3\u30d4\u30fc\u3055\u308c\u308b\u3002<a href=\"https:\/\/cloud.google.com\/appengine\/docs\/standard\/python\/tools\/using-libraries-python-27#pip_requirements\">App Engine \u306b\u30c7\u30d7\u30ed\u30a4\u6642\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u308b\u3002<\/a><\/p>\n<\/blockquote>\n<pre class=\"prettyprint linenums\">(gaeflask) PS C:\\workspaces\\gcp\\dokobingo&gt; pip install -t lib -r requirements.txt<\/pre>\n<h2>2.VS Code \u304b\u3089\u30c7\u30d0\u30c3\u30b0\u3092\u884c\u3046<\/h2>\n<p>\u57fa\u672c\u7684\u306b\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306b\u5f93\u3046\u3002<\/p>\n<p><a title=\"https:\/\/code.visualstudio.com\/docs\/python\/debugging\" href=\"https:\/\/code.visualstudio.com\/docs\/python\/debugging\">https:\/\/code.visualstudio.com\/docs\/python\/debugging<\/a><\/p>\n<p>Google App Engine \u306f\u81ea\u8eab\u3067\u8d77\u52d5\u3059\u308b\u305f\u3081\u3001VS Code \u30c7\u30d0\u30c3\u30ac\u306f\u76f4\u63a5\u5229\u7528\u3067\u304d\u306a\u3044\u3002\u4ee3\u308f\u308a\u306b\u3001ptvsd \u3092\u4f7f\u7528\u3057\u3066\u3001Google App Engine \u3092VS Code\u304c\u30c7\u30d0\u30c3\u30ac\u3092\u30a2\u30bf\u30c3\u30c1\u3067\u304d\u308b\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<h3>3.1&nbsp; ptvsd \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h3>\n<p><a href=\"https:\/\/pypi.python.org\/pypi\/ptvsd\">https:\/\/pypi.python.org\/pypi\/ptvsd<\/a><\/p>\n<p>\u4e0a\u8a18\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3002<\/p>\n<p>VS Code 1.19.1 \u3001Python 2.7 32 bit\u74b0\u5883\u3067\u691c\u8a3c\u3057\u3066\u3044\u308b\u304c\u3001\u73fe\u6642\u70b9\u3067\u6700\u65b0\u7248\u306e\u3001<\/p>\n<p>pytvsd 3.2.1 \u3067\u306f\u30c7\u30d0\u30c3\u30ac\u304c\u30af\u30e9\u30c3\u30b7\u30e5\u3057\u3066\u3057\u307e\u3046\u30023.2.0 \u30013.1.0 \u3068\u8a66\u3057\u305f\u304c\u3044\u305a\u308c\u3082NG\u3002<\/p>\n<p>\u7d50\u5c40 pytvsd 3.0.0 \u304c\u5229\u7528\u3067\u304d\u305f\u306e\u3067\u3053\u3061\u3089\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<p>\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u5c55\u958b\u3059\u308b\u3002<\/p>\n<h3>3.2 \u30bf\u30b9\u30af\u306e\u69cb\u6210<\/h3>\n<p>tasks.json \u306e\u69cb\u6210\u3092\u884c\u3046\u3002<\/p>\n<p><a title=\"https:\/\/vscode-doc-jp.github.io\/docs\/userguide\/tasks.html\" href=\"https:\/\/vscode-doc-jp.github.io\/docs\/userguide\/tasks.html\">https:\/\/vscode-doc-jp.github.io\/docs\/userguide\/tasks.html<\/a><\/p>\n<p>dev_appserver.py \u306e\u30d1\u30b9\u3092Google SDK\u306e\u30d1\u30b9\u306b\u5909\u66f4\u3059\u308b\u3002<\/p>\n<p><pre class=\"prettyprint linenums\">  {\r\n      \"version\": \"0.1.0\",\r\n      \"command\": \"python\",\r\n      \"isShellCommand\": true,\r\n      \"showOutput\": \"always\",\r\n      \"args\": [\r\n          \"C:\\\\Programs\\\\Google\\\\Cloud SDK\\\\google-cloud-sdk\\\\bin\\\\dev_appserver.py\",\r\n          \"--python_startup_script=${workspaceFolder}\/pydev_startup.py\",\r\n          \"--automatic_restart=no\",\r\n          \"--max_module_instances=default:1\",\r\n          \"${workspaceFolder}\/app.yaml\"\r\n      ]\r\n  }\r\n<\/pre>\n<h3>3.3 \u30c7\u30d0\u30c3\u30b0\u69cb\u6210<\/h3>\n<p>\u30c7\u30d0\u30c3\u30b0\u30d3\u30e5\u30fc\u306e\u30c8\u30c3\u30d7\u30d0\u30fc\u306b\u3042\u308b\u6b6f\u8eca\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001VS Code\u306f\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u306e.vscode\u30d5\u30a9\u30eb\u30c0\u30fc\u306e\u4e0b\u306blaunch.json\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u8ffd\u52a0<\/p>\n<p><a title=\"https:\/\/vscode-doc-jp.github.io\/docs\/userguide\/debugging.html\" href=\"https:\/\/vscode-doc-jp.github.io\/docs\/userguide\/debugging.html\">https:\/\/vscode-doc-jp.github.io\/docs\/userguide\/debugging.html<\/a><\/p>\n<pre class=\"prettyprint linenums\">{\r\n    \"name\": \"Python: GAE(Attach)\",\r\n    \"type\": \"python\",\r\n    \"request\": \"attach\",\r\n    \"localRoot\": \"${workspaceFolder}\",\r\n    \"remoteRoot\": \"${workspaceFolder}\",\r\n    \"port\": 3000,\r\n    \"secret\": \"gae\",\r\n    \"host\": \"localhost\",\r\n    \"preLaunchTask\": \"python\"\r\n},<\/pre>\n<h2>3.\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c8<\/h2>\n<p>\u5b9f\u884c\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">Traceback (most recent call last):\r\n  File \"C:\\Programs\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\google_appengine\\google\\appengine\\runtime\\wsgi.py\", line 240, in Handle\r\n    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())\r\n  File \"C:\\Programs\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\google_appengine\\google\\appengine\\runtime\\wsgi.py\", line 299, in _LoadHandler\r\n    handler, path, err = LoadObject(self._handler)\r\n  File \"C:\\Programs\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\google_appengine\\google\\appengine\\runtime\\wsgi.py\", line 85, in LoadObject\r\n    obj = __import__(path[0])\r\n  File \"C:\\workspaces\\gcp\\dokobingo\\main.py\", line 19, in <module>\r\n    from flask import Flask, render_template, request\r\nImportError: No module named flask<\/module><\/pre>\n<p><a href=\"https:\/\/github.com\/pallets\/click\/issues\/594\">https:\/\/github.com\/pallets\/click\/issues\/594<\/a><\/p>\n<p>\u3092\u53c2\u8003\u306b\u3001appengine_config.py \u3092\u4ee5\u4e0b\u306b\u66f8\u304d\u63db\u3048\u308b<\/p>\n<p><pre class=\"prettyprint linenums\">import os\r\nimport sys\r\nfrom google.appengine.ext import vendor\r\n \r\nvendor.add('lib')\r\n\r\nprint os.environ.get('SERVER_SOFTWARE', '')\r\n\r\nif os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):\r\n    sys.path.insert(0, 'lib.zip')\r\nelse:\r\n    if os.name == 'nt':\r\n        os.name = None\r\n        sys.platform = ''\r\n<\/pre>\n<h2>4.\u5b9f\u884c<\/h2>\n<p>\u672c\u6765\u306f\u3001\u30c7\u30d0\u30c3\u30b0\u30d3\u30e5\u30fc\u304b\u3089\u3001\u4e0a\u8a183.3\u3067\u8ffd\u52a0\u3057\u305f\u69cb\u6210\u3092\u5b9f\u884c\u3059\u308c\u3070\u3088\u3044\u306f\u305a\u3060\u304c\u3001\u3046\u307e\u304f\u30a2\u30bf\u30c3\u30c1\u3055\u308c\u306a\u3044\u305f\u3081\u3001\u5225\u3005\u306b\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/4efbdf828cc5_9A97\/run_debug.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"313\" title=\"run_debug\" style=\"display: inline; background-image: none;\" alt=\"run_debug\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/4efbdf828cc5_9A97\/run_debug_thumb.jpg\" border=\"0\"><\/a><\/p>\n<h3>4.1 \u958b\u767a\u30b5\u30fc\u30d0\u30fc\u306e\u5b9f\u884c<\/h3>\n<p>\u30b3\u30de\u30f3\u30c9\u30d1\u30ec\u30c3\u30c8(Ctrl+Shift+p) \u304b\u3089\u3001\u30d3\u30eb\u30c9\u30bf\u30b9\u30af\u306e\u5b9f\u884c\u3002\u3053\u308c\u3067\u958b\u767a\u30b5\u30fc\u30d0\u30fc\u304c\u8d77\u52d5\u3055\u308c\u308b\u3002<a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/4efbdf828cc5_9A97\/run_task.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"415\" height=\"122\" title=\"run_task\" style=\"display: inline; background-image: none;\" alt=\"run_task\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/4efbdf828cc5_9A97\/run_task_thumb.jpg\" border=\"0\"><\/a><\/p>\n<h3>4.2 \u305d\u306e\u5f8c\u3001\u30c7\u30d0\u30c3\u30b0\u30d3\u30e5\u30fc\u304b\u3089\u3001Python:GAE(Attach) \u3092\u5b9f\u884c<\/h3>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/4efbdf828cc5_9A97\/debug_desktop.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"619\" height=\"350\" title=\"debug_desktop\" style=\"display: inline; background-image: none;\" alt=\"debug_desktop\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/4efbdf828cc5_9A97\/debug_desktop_thumb.jpg\" border=\"0\"><\/a><\/p>\n<p>\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u3067\u6b62\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u7684\u306b\u3001https:\/\/cloud.google.com\/appengine\/docs\/standard\/python\/getting-started\/python-standard-env \u3092\u5b9f\u73fe\u3059\u308b\u3002 \u30b5\u30f3\u30d7\u30eb\u3092\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[101,100,19,20],"tags":[],"class_list":["post-530","post","type-post","status-publish","format-standard","hentry","category-flask","category-google-cloud-platform","category-googleappengine","category-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}