如何在AWS Elastic Beanstalk或Google App Engine上使用未安装pip的Python库?
我有一个使用Python库PyDDE的flaskweb服务,它分布在PyPI上,但不知何故无法安装pip。我可以使用如何在AWS Elastic Beanstalk或Google App Engine上使用未安装pip的Python库?,python,amazon-web-services,google-app-engine,pip,amazon-elastic-beanstalk,Python,Amazon Web Services,Google App Engine,Pip,Amazon Elastic Beanstalk,我有一个使用Python库PyDDE的flaskweb服务,它分布在PyPI上,但不知何故无法安装pip。我可以使用pip-install-git在本地环境中安装这个库+https://github.com/hensing/PyDDE.git或克隆并安装setup.py 但是,当我尝试在AWS Elastic Beanstalk或Google App Engine Flexible环境中上载并构建项目时,他们无法找到与此库匹配的发行版,这就成了一个问题 有解决这个问题的方法吗 以下是来自GAE
pip-install-git在本地环境中安装这个库+https://github.com/hensing/PyDDE.git
或克隆并安装setup.py
但是,当我尝试在AWS Elastic Beanstalk或Google App Engine Flexible环境中上载并构建项目时,他们无法找到与此库匹配的发行版,这就成了一个问题
有解决这个问题的方法吗
以下是来自GAE Flexible的错误消息:
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
-e git+git://github.com/hensing/PyDDE.git#egg=PyDDE
-e git://https://github.com/hensing/PyDDE.git#egg=PyDDE
更新:
我在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
-e git+git://github.com/hensing/PyDDE.git#egg=PyDDE
-e git://https://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.
- 在项目文件夹中创建文件夹,例如
lib
- 使用
pip Install-t
- 在与
文件相同的文件夹中创建一个名为app.yaml
的文件,并按如下方式编辑它:appengine\u config.py
from google.appengine.ext import vendor vendor.add('lib') # Folder name
- 部署
- 将其添加到您的
requirements.txt中,而不是PyDDE
:
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
-e git+git://github.com/hensing/PyDDE.git#egg=PyDDE
-e git://https://github.com/hensing/PyDDE.git#egg=PyDDE
AWS Elastic Beanstalk不接受此要求。txt
看来你已经把git+git://github.com/hensing/PyDDE.git#egg=PyDDE
输入您的requirements.txt。从文件中删除git+
和#egg=PyDDE
(如上所述),然后它就可以工作了。我可以通过以下方式解决类似的问题:
创建一个配置文件来安装git,因为它不是预装在EB上的:
- 路径:root/.ebextensions
- 文件:conf.config(名称无关紧要,扩展名需要是config)
将以下内容添加到conf.config文件:
packages:
yum:
git: []
将以下内容添加到requirements.txt:
-e git://github.com/hensing/PyDDE.git#egg=PyDDE
重新运行eb部署
链接:
-您可以分享错误消息吗?您是否可以将requirements.txt
的内容放入您的问题中?如果您使用requirements.txt,是否可以尝试添加-egit://https://github.com/hensing/PyDDE.git
转换为requirements.txt
as`是的,我确实遵循了这个程序。但它仍然在部署时基于requirements.txt
在Docker容器中构建所有库。@EvyatarMeged这只适用于标准环境,不适用于灵活的环境。GAE似乎需要此部分#egg=PyDDE
,否则无效。