在带有外部库的Google Cloud App Engine上部署Django项目 [英] Deploy Django project on google Cloud App Engine with external libraries

查看:498
本文介绍了在带有外部库的Google Cloud App Engine上部署Django项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!

我需要在Python Django上部署一个应用程序,并附带以下库文件:


  • 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

  • 请求== 2.18.1

  • urllib3 == 1.21.1



我必须将它连接到PostgreSQL数据库。

因此,我应该使用哪种环境?标准还是灵活?



我应该如何将这些库安装到环境中?

PS



我尝试了一切: app.yaml appengine_config.py ,我已经将libs直接安装到源代码('libs'文件夹),并将库添加到 app.yaml 甚至 google.appengine

最后我有: >

不正确配置:加载psycopg2模块时出错:动态模块
没有定义init函数(init_psycopg)


解决方案


因此,我应该使用哪种环境?标准还是灵活?


您的出发点应该是选择一个App Engine环境指南,并考虑到您的所有要求。


我必须将它连接到PostgreSQL数据库。

这个要求使得选择变得非常简单。从从App Engine进行连接


此页面提供特定于语言的链接,介绍如何通过
从App Engine灵活环境
应用程序建立连接到云SQL for PostgreSQL实例。

 注意:不支持从App Engine标准环境应用程序
到PostgreSQL实例的连接。


如此灵活的环境。


我应该如何将这些库安装到环境中?

这取决于您使用的环境。你试过的是标准的env方式。

在灵活的环境中,依赖关系的处理方式不同。来自相关性


运行时查找 $ requirements.txt 文件到您的
应用程序的源目录中,并使用 pip 在启动应用程序之前安装任何
依赖项。有关
声明和管理包的更多信息,请参阅使用Python库



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)

解决方案

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

这篇关于在带有外部库的Google Cloud App Engine上部署Django项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆