2

I developed a web application based on Python 3.6 and Django 2.0 and want to deploy in Google App Engine for the first time. When I tried to deploy (gcloud app deploy) it, it did not go through and showed me the error message as follows:

(acct) C:\Users\tsjee_000\dev\acct\src>gcloud app deploy
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [C:\Users\tsjee_000\dev\acct\src\app.yaml]
libraries entries are only supported by the "python27" runtime
  in "C:\Users\tsjee_000\dev\acct\src\app.yaml", line 34, column 13

app.yaml:

runtime: python
api_version: 1
threadsafe: yes
env: flex
entrypoint: gunicorn -b :$PORT main:app

handlers:
- url: /static
  static_dir: static/
- url: .*
  script: acct.wsgi.application

libraries:
- name: MySQLdb
  version: 1.2.5

Does not GAE support Python 3 and Django 2 yet? I looked for the answer and tried in many ways but it did not work.

Guillermo Cacheda
  • 2,162
  • 14
  • 23
TS Jee
  • 121
  • 1
  • 4
  • 12

2 Answers2

5

You're mixing up standard environment app.yaml config elements (libraries in your case) into a flexible environment app.yaml configuration file, which causes the error you see.

Notes:

  • the standard environment only supports python 2.7, which is where the version mentioned in the error message comes from
  • depending on which such element is introduced there may be no error generated, things may be silently not working - your handlers configs, for example, also standard environment specific

In the flexible environment your dependencies are managed:

Maybe of interest: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Yes, I referred to many app.yaml samples and mixed them without environment consideration. So I can go further after update, but another error occurred like this, "Failed to find application object 'app' in 'acct'". I think this issue is related to the coding, "entrypoint: gunicorn -b :$PORT acct.wsgi" in "app.yaml" . I know this is another issue. But if you give me any clue it will be a good help. Thank you very much for the solution. – TS Jee Aug 03 '18 at 19:06
  • do you have an `acct.py` file with an `app` variable pointing to your app? See [Application startup](https://cloud.google.com/appengine/docs/flexible/python/runtime#application_startup) – Dan Cornilescu Aug 03 '18 at 19:16
  • Mine is a django project and project name is 'acct' which has 'manage.py'. I don't know where 'app' comes from. – TS Jee Aug 03 '18 at 19:53
  • I didn't use django. Try `mysite.wsgi`, based on this guide: https://cloud.google.com/python/django/flexible-environment – Dan Cornilescu Aug 04 '18 at 02:13
  • I think 'mysite' is a sample project name in the guide. My project name is 'acct'. Today, when I tried the same command again, it worked. I don' know why... though. – TS Jee Aug 07 '18 at 04:54
-1

Try adding:

runtime_config:
    python_version: 3

Via https://cloud.google.com/appengine/docs/flexible/python/runtime

kwamz
  • 1
  • 1