部署到AWS时无效的requirements.txt。 PIP无法安装lxml [英] Invalid requirements.txt on deploying to AWS. Pip couldn't install lxml

查看:382
本文介绍了部署到AWS时无效的requirements.txt。 PIP无法安装lxml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Flask应用程序部署到AWS EC2实例时遇到问题。可能用 pip 安装 lxml 。但是我不知道该如何解决这个问题。

AWS EC2:

  b $ p 
$ b

eb create

  CalledProcessError:Command'/ opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt'返回非零退出状态1. 

来自日志:

  src / lxml / lxml.etree.c:200873:error:'XML_XPATH_INVALID_ARITY '未声明(首次在此函数中使用)
src / lxml / lxml.etree.c:200883:错误:'XML_XPATH_INVALID_CTXT_SIZE'未声明(首次在此函数中使用)
src / lxml / lxml.etree。 c:200893:error:'XML_XPATH_INVALID_CTXT_POSITION'未声明(在此函数中首次使用)
src / lxml / lxml.etree.c:201123:错误:'LIBXSLT_VERSION'未声明(在此函数中首次使用)
src / lxml / lxml.etree.c:201135:错误:'xsltLibxsltVersion'u ndeclared(在此函数中首次使用)
src / lxml / lxml.etree.c:201147:错误:'__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER'未声明(在此函数中首次使用)
src / lxml / lxml.etree.c :201147:错误:'xsltDocDefaultLoader'未声明(首次在此函数中使用)
src / lxml / lxml.etree.c:201156:错误:'xsltDocLoaderFunc'未声明(首次在此函数中使用)
src /lxml/lxml.etree.c:201156:error:expected')'before'__pyx_f_4lxml_5etree__xslt_doc_loader'
error:command'gcc'failed with exit status 1

------ ----------------------------------
命令/ opt / python / run / venv / bin /python2.7 -cimport setuptools,tokenize; __ file __ ='/ tmp / pip-build -fJYICo / lxml / setup.py'; exec(compile(getattr(tokenize,'open',open)(__ file __)。read ().replace('\r\\\
','\\\
'),__file__,'exec'))install --record /tmp/pip-iWirgM-record/install-record.txt --single -version-external-managed --compile --install-头文件/opt/python/run/venv/include/site/python2.7/lxml失败,错误代码1在/ tmp / pip-build-fJYICo / lxml
2015-08-04 07:00:15,710错误安装依赖关系时出错:命令'/ opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt'返回非零退出状态1
Traceback调用最后一个):

install_dependencies()
文件中的/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py,第22行,/ opt / elasticbeanstalk / hooks /appdeploy/pre/03deploy.py,第18行,在install_dependencies
check_call('%s install -r%s'%(os.path.join(APP_VIRTUAL_ENV,'bin','pip'),requirements_file ),shell = True)
在check_call中输入540行/usr/lib64/python2.7/subprocess.py
提升CalledProcessError(retcode,cmd)
CalledProcessError: / opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt'返回非零退出状态1(Executor :: NonZeroExitStatus)


[2015-08-04T07:00:15.731Z]信息[7052] - [CMD-Startup / StartupStage0 / AppDeployPreHook / 03deploy.py]:活动失败。
[2015-08-04T07:00:15.731Z]信息[7052] - [CMD-Startup / StartupStage0 / AppDeployPreHook]:活动失败。
[2015-08-04T07:00:15.731Z]信息[7052] - [CMD-Startup / StartupStage0]:活动失败。
[2015-08-04T07:00:15.749Z]信息[7052] - [CMD-Startup]:已完成的活动。结果:
命令CMD-Startup(阶段0)失败。

以及requirements.txt文件:

  alabaster == 0.7.6 
alembic == 0.7.6
aniso8601 == 1.0.0
Babel == 1.3
beautifulsoup4 = = 4.4.0
blinker == 1.3
boto == 2.38.0
docutils == 0.12
Flask == 0.10.1
Flask-Bower == 1.2 .1
Flask-Cors == 2.0.1
Flask-DebugToolbar == 0.10.0
Flask-Login == 0.2.11
Flask-Mail == 0.9.1
Flask-RESTful == 0.3.3
Flask-WTF == 0.11
itsdangerous == 0.24
Jinja2 == 2.7.3
lxml == 3.4.4
Mako == 1.0.1
Markdown == 2.6.2
MarkupSafe == 0.23
nose == 1.3.6
pep8 == 1.6.2
psycopg2 == 2.6
Pygments == 2.0.2
pytz == 2015.4
== 2.7.0
== == 1.9.0
snowballstemmer = = 1.2.0
Sphinx == 1.3.1
sphinx-rtd-theme == 0.1.8
SQLAlchemy == 1.0.0
Werkzeug == 0.10.4
WTForms == 2.0.2

首先,我正确地说安装 LXML
如果是这样,你知道如何解决它的AWS,因为在我的本地计算机(Mac OS 10.9.5)我没有这个错误。

解决方案

我猜是这样。

尝试下面的命令,然后重新安装lxml:

  $ sudo apt-get install libxml2-dev libxslt1-dev python-dev 

如果再次失败,请检查以下问题,它们与lxml安装问题有关:


I have a problem deploying Flask application to AWS EC2 instance. Probably with pip installing lxml. But I don't know how to solve the issue.

AWS EC2:

Platform: 64bit Amazon Linux 2015.03 v1.4.6 running Python 2.7

From CLI on eb create:

CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1. 

From logs:

src/lxml/lxml.etree.c:200873: error: ‘XML_XPATH_INVALID_ARITY’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:200883: error: ‘XML_XPATH_INVALID_CTXT_SIZE’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:200893: error: ‘XML_XPATH_INVALID_CTXT_POSITION’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:201123: error: ‘LIBXSLT_VERSION’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:201135: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:201147: error: ‘__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:201147: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:201156: error: ‘xsltDocLoaderFunc’ undeclared (first use in this function)
  src/lxml/lxml.etree.c:201156: error: expected ‘)’ before ‘__pyx_f_4lxml_5etree__xslt_doc_loader’
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
Command "/opt/python/run/venv/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-fJYICo/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-iWirgM-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/python/run/venv/include/site/python2.7/lxml" failed with error code 1 in /tmp/pip-build-fJYICo/lxml
2015-08-04 07:00:15,710 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
Traceback (most recent call last):
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
  install_dependencies()
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
  check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
File "/usr/lib64/python2.7/subprocess.py", line 540, 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 1 (Executor::NonZeroExitStatus)


[2015-08-04T07:00:15.731Z] INFO  [7052]  - [CMD-Startup/StartupStage0/AppDeployPreHook/03deploy.py] : Activity failed.
[2015-08-04T07:00:15.731Z] INFO  [7052]  - [CMD-Startup/StartupStage0/AppDeployPreHook] : Activity failed.
[2015-08-04T07:00:15.731Z] INFO  [7052]  - [CMD-Startup/StartupStage0] : Activity failed.
[2015-08-04T07:00:15.749Z] INFO  [7052]  - [CMD-Startup] : Completed activity. Result:
Command CMD-Startup(stage 0) failed.

And the requirements.txt file:

alabaster==0.7.6
alembic==0.7.6
aniso8601==1.0.0
Babel==1.3
beautifulsoup4==4.4.0
blinker==1.3
boto==2.38.0
docutils==0.12
Flask==0.10.1
Flask-Bower==1.2.1
Flask-Cors==2.0.1
Flask-DebugToolbar==0.10.0
Flask-Login==0.2.11
Flask-Mail==0.9.1
Flask-RESTful==0.3.3
Flask-WTF==0.11
itsdangerous==0.24
Jinja2==2.7.3
lxml==3.4.4
Mako==1.0.1
Markdown==2.6.2
MarkupSafe==0.23
nose==1.3.6
pep8==1.6.2
psycopg2==2.6
Pygments==2.0.2
pytz==2015.4
requests==2.7.0
six==1.9.0
snowballstemmer==1.2.0
Sphinx==1.3.1
sphinx-rtd-theme==0.1.8
SQLAlchemy==1.0.0
Werkzeug==0.10.4
WTForms==2.0.2

First, am I right that the problem with installing lxml? If so, do you know how to solve it for AWS because on my local computer (Mac OS 10.9.5) I hadn't that error.

解决方案

I guess so.

try the following command, and then reinstall lxml:

$ sudo apt-get install libxml2-dev libxslt1-dev python-dev

If failed again, have a check the following questions, they're related to lxml installation problems:

这篇关于部署到AWS时无效的requirements.txt。 PIP无法安装lxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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