如何在AWS Elastic Beanstalk或Google App Engine上使用没有PIP安装的Python库



我使用Python库Pydde有一个烧瓶Web服务,该服务是在PYDD上分发的,但无法安装PIP。我可以使用pip install git+https://github.com/hensing/PyDDE.git或克隆并安装setup.py在本地环境上安装此库。

但是,当我尝试在AWS弹性豆stalk或Google App Engine灵活的环境上上传和构建项目时,这成为他们找不到该库的匹配分布的问题。

是否有解决这个问题的解决方法?

这是GAE灵活的错误消息:

Step #1:   Could not find a version that satisfies the requirement PyDDE (from -r requirements.txt (li
ne 7)) (from versions: )
Step #1: No matching distribution found for PyDDE (from -r requirements.txt (line 7))
Step #1: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Finished Step #1
ERROR
ERROR: build step "gcr.io/cloud-builders/docker@sha256:331786b295647a4560ed004a46761ee91409e754df7ffa7
54a67000bd020729a" failed: exit status 1
Step #1:
------------------------------------------------------------------------------------------------------
ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/buil
ds/6ace1019-8bf5-434b-b916-5c6cae84de9f?project=project-190120 Failure status: UNKNOWN: Err
or Response: [2] Build failed; check build logs for details

这是我的requirements.txt

Flask==0.12.2
Werkzeug==0.12.2
gunicorn==19.7.1
pandas>0.20.0
numpy>1.13.0
scipy>0.19.0
PyDDE
google-api-python-client

更新:

我在 requirements.txt中添加了这一行:

-e git+git://github.com/hensing/PyDDE.git#egg=PyDDE

它适用于Gae。

谢谢@hansaplast !!

但是,AWS Elastic Beanstalk不接受此requirements.txt。它引发了此错误:

INFO: Created CloudWatch alarm named: awseb-e-3tu2ajdxug-stack-AWSEBCloudwatchAlarmLow-8NOPISSRAAEH
ERROR: Your requirements.txt is invalid. Snapshot your logs for details.
ERROR: [Instance: i-03e92fa3c58b6e010] Command failed on instance. Return code: 1 Output: (TRUNCATED).
..)
  File "/usr/lib64/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 2.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

我能够通过以下方式解决类似的问题:

创建一个配置文件以安装git,因为这不是在EB上预安装的:

  • 路径:root/.ebextensions
  • 文件:conf.config(名称无关紧要,扩展需要配置)

将以下内容添加到conf.config文件:

packages:
  yum:
    git: []

将以下内容添加到您的要求中。txt:

-e git://github.com/hensing/PyDDE.git#egg=PyDDE

重新运行eb deploy

链接: - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-methods-during.html#configuration-options-options-during-ebcli-ebcli-ebextensions

  • 在您的项目文件夹中创建一个文件夹,例如lib
  • 使用pip install -t <dir>
  • 将想要的库安装到该文件夹中
  • 在与app.yaml文件的同一文件夹中创建一个名为appengine_config.py的文件,并按照以下方式进行编辑:

    from google.appengine.ext import vendor 
    vendor.add('lib') # Folder name
    
  • 部署

而不是PyDDE,将其添加到您的requirements.txt

-e git://https://github.com/hensing/PyDDE.git#egg=PyDDE

aws弹性beanstalk不接受此要求。txt

看来您已将git+git://github.com/hensing/PyDDE.git#egg=PyDDE放入您的需求.txt。从文件中删除git+#egg=PyDDE(如上所述),然后应起作用。

最新更新