nownab.log

nownabe's daily posts

App Engineのdev_appserver.pyが起動しなかった

Posted on Jul 29, 2017

はじめに

Quick StartのTest the applicationでこんな感じでエラーがでたのでこんな感じで対処していった。

ModuleNotFoundError: No module named ‘setup’

Download the SDK for App Engineをやれという話でした。

$ dev_appserver.py app.yaml
Traceback (most recent call last):
  File "/home/nownabe/tmp/google-cloud-sdk/bin/dev_appserver.py", line 11, in <module>
    import bootstrapping.bootstrapping as bootstrapping
  File "/home/nownabe/tmp/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
    import setup
ModuleNotFoundError: No module named 'setup'

$ gcloud components install app-engine-go
pyenv: python2: command not found

The `python2' command exists in these Python versions:
  2.7.13

$ dev_appserver.py app.yaml 


Updates are available for some Cloud SDK components.  To install them,
please run:
  $ gcloud components update

This action requires the installation of components: [app-engine-
python, app-engine-go]


Your current Cloud SDK version is: 145.0.0
Installing components from version: 145.0.0

┌────────────────────────────────────────────────────┐
│        These components will be installed.         │
├───────────────────────────────┬─────────┬──────────┤
│              Name             │ Version │   Size   │
├───────────────────────────────┼─────────┼──────────┤
│ App Engine Go (Linux, x86_64) │  1.9.50 │ 47.9 MiB │
│ App Engine Go Extensions      │         │          │
│ gcloud app Python Extensions  │  1.9.50 │  7.2 MiB │
└───────────────────────────────┴─────────┴──────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?  

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go (Linux, x86_64)                ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go Extensions                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud app Python Extensions                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation          ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done.                                        

Update done!

Restarting command:
  $ dev_appserver.py app.yaml

Traceback (most recent call last):
  File "/home/nownabe/tmp/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 101, in <module>
    _run_file(__file__, globals())
  File "/home/nownabe/tmp/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/home/nownabe/tmp/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 35, in <module>
    from google.appengine.tools.devappserver2 import api_server
  File "/home/nownabe/tmp/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 47, in <module>
    from google.appengine.api.logservice import logservice_stub
  File "/home/nownabe/tmp/google-cloud-sdk/platform/google_appengine/google/appengine/api/logservice/logservice_stub.py", line 24, in <module>
    import sqlite3
  File "/home/nownabe/.anyenv/envs/pyenv/versions/2.7.13/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/home/nownabe/.anyenv/envs/pyenv/versions/2.7.13/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3

ImportError: No module named _sqlite3

SQLite3のモジュールがないとだめらしい。 sqliteをいれて、Pythonをインストールし直す。 pyenvを使っているのでこんな感じ。

$ pyenv uninstall 2.7.13
$ sudo dnf install -y sqlite-devel
$ pyenv install 2.7.13

できた

起動した。

$ dev_appserver.py app.yaml
INFO     2017-07-29 10:27:38,793 devappserver2.py:764] Skipping SDK update check.
INFO     2017-07-29 10:27:38,845 api_server.py:268] Starting API server at: http://localhost:40061
INFO     2017-07-29 10:27:38,937 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO     2017-07-29 10:27:38,938 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO     2017-07-29 10:28:30,900 module.py:806] default: "GET / HTTP/1.1" 200 13
INFO     2017-07-29 10:28:31,087 module.py:806] default: "GET /favicon.ico HTTP/1.1" 200 13