Amazon ec2 部署到AWS时requirements.txt无效。Pip不能';t安装lxml

Amazon ec2 部署到AWS时requirements.txt无效。Pip不能';t安装lxml,amazon-ec2,flask,pip,lxml,requirements.txt,Amazon Ec2,Flask,Pip,Lxml,Requirements.txt,我在将Flask应用程序部署到AWS EC2实例时遇到问题。可能使用pip安装lxml。但我不知道如何解决这个问题 AWS EC2: Platform: 64bit Amazon Linux 2015.03 v1.4.6 running Python 2.7 从eb create上的CLI: CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requiremen

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

AWS EC2:

Platform: 64bit Amazon Linux 2015.03 v1.4.6 running Python 2.7
eb create
上的CLI:

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

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.
以及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
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
首先,安装
lxml
的问题是否正确? 如果是这样的话,你知道如何为AWS解决这个问题吗?因为在我的本地计算机(Mac OS 10.9.5)上我没有这个错误。

我想是的

请尝试以下命令,然后重新安装lxml:

$ sudo apt-get install libxml2-dev libxslt1-dev python-dev
如果再次失败,请检查以下问题,它们与lxml安装问题有关:

    • 我想是的

      请尝试以下命令,然后重新安装lxml:

      $ sudo apt-get install libxml2-dev libxslt1-dev python-dev
      
      如果再次失败,请检查以下问题,它们与lxml安装问题有关: