Deploy Django project on google Cloud App Engine w

2019-07-18 17:43发布

Good day!

I need to deploy an app on Python Django with following libs:

  • certifi==2017.4.17
  • chardet==3.0.4
  • Django==1.11.2
  • httplib2==0.10.3
  • idna==2.5
  • oauth2==1.9.0.post1
  • psycopg2==2.7.1
  • pytz==2017.2
  • requests==2.18.1
  • urllib3==1.21.1

And I have to connect it to PostgreSQL database.

So, what environment shall I use? Standard or Flexible?

And how shall I install those libraries to the environment?

P.S.

I've tried everything: app.yaml, appengine_config.py, I has installed libs directly to source ('libs' folder), and adding libs to app.yaml, and even google.appengine.ext.ndb.django_middleware.NdbDjangoMiddleware

In the end I have:

ImproperlyConfigured: Error loading psycopg2 module: dynamic module does not define init function (init_psycopg)

1条回答
趁早两清
2楼-- · 2019-07-18 18:02

So, what environment shall I use? Standard or Flexible?

Your starting point should be the Choosing an App Engine Environment guide, taking into consideration all your requirements.

And I have to connect it to PostgreSQL database.

This requirement makes the choice pretty easy. From Connecting from App Engine:

This page provides language-specific links to informaton about how to set up a connection from an App Engine flexible environment application to a Cloud SQL for PostgreSQL instance.

Note: Connection from an App Engine standard environment application
to a PostgreSQL instance is not supported.

So flexible environment it is.

And how shall I install those libraries to the environment?

This dependends on the environment you use. What you tried was the standard env way.

In the flexible environment dependencies are handled differently. From Dependencies:

The runtime looks for a requirements.txt file in your application's source directory and uses pip to install any dependencies before starting your application. For more information on declaring and managing packages, see Using Python Libraries

查看更多
登录 后发表回答