将Python requirements.txt安装到Elastic Beanstalk上的PHP应用程序时非常困难 .
最初我曾质疑Deploy multiple platforms to Elastic Beanstalk (PHP/Python)的能力 . 虽然这不是开箱即用的,但可以运行pre-install commands via .ebextentions
这导致创建.ebextentions / install_python_requirements.config
container_commands:
python_req:
command: 'pip install -r /var/app/ondeck/requirements.txt'
麻烦是,现在 lxml
,需求中的依赖,在部署过程中始终失败 . 奇怪的是, ssh
直接进入EC2实例然后运行 pip install -r requirements.txt
完成没有问题 .
为什么依赖安装通过直接 ssh
访问成功,但在部署期间使用 eb deploy
和 install_python_requirements.config
失败?
/var/log/eb-activity.log失败
creating build/temp.linux-x86_64-2.7/src/lxml
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-A6NhcA/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
gcc: error trying to exec 'cc1': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-A6NhcA/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gSsRbZ-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-A6NhcA/lxml
(ElasticBeanstalk::ExternalInvocationError)
1 回答
事实证明,问题最终成为系统
$PATH
. 看来,在eb deploy
期间,系统路径未设置 .pip install
能够开始,因为系统PATH可用于部署过程 . 但是,该系统PATH变量未传递到pip
进程 . 因此,当尝试后续调用pip时,它们会因为无法找到应用程序路径而失败 . 通过向install_python_requirements.config添加日志可以证明这一点然后检查/var/log/eb-activity.log以获取上面日志命令的输出,并注意到
$PATH
的缺失解决方案是通过另一个.ebextentions / var.config手动设置PATH
这允许在
eb deploy
进程中成功完成requirements.txt