LoginSignup
0
3

More than 5 years have passed since last update.

Intellij IdeaでGoogle App Engine/Python のアプリを書く時の設定

Last updated at Posted at 2017-06-17

自分用の備忘録メモ。

対象のバージョンは以下
Screen_Shot_2017-06-17_at_8_53_53.png

python プラグインをインストール

そもそもPythonのプラグインをインストールしておきます。これである程度のPycharm相当の機能が使えます
Preferences.png

ProjectStructureを選択

Screen_Shot_2017-06-17_at_8_49_27.png

Google App EngineのSDKへのパスを指定

LocalのマシンにインストールしているGoogle App EngineのSDKへのパスを指定します。
Project_Structure.png

Libフォルダーを指定

Pipでインストールするライブラリは、プロジェクト直下のLibフォルダーに入れるのが公式サンプルにあるパターンなのでそれが良いかと思います。

Flaskでのサンプル
https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/flask/hello_world

以下のように -t でインストールします。

pip install -t lib -r requirements.txt

↓以下のような appengine_config.py ファイルを入れておきます。
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/flask/hello_world/appengine_config.py

from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')

ちなみにPipでインストールして使えるのは、Pythonのみで構成するものです。それ以外のものは、Googleが用意しているものを app.yamlで宣言すると使えます。


libraries:
- name: jinja2
  version: latest

以下にリストがあります。
https://cloud.google.com/appengine/docs/standard/python/tools/built-in-libraries-27

ここまでの準備をした上で、Libフォルダーを選択してResourcesに指定するとLibフォルダーにインストールしたものがIntellijでちゃんと参照してくれるようになります。

Screen_Shot_2017-06-17_at_9_05_59.png

これですべての依存ライブラリがIntellijから認識されている状態になりました。
main_py_-_monitoring_-____dev_monitoring_.png

Jinja2テンプレートを認識させる

ほっておくとJinja2テンプレートが認識されません。これは不便なので、PreferencesからPythont Template Languageを開いて設定します。

Preferences.png

。。ここまで書いておとなしくPycharm使ったほうがいい気がしてきました。

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3