在部署到AWS无效requirements.txt。 皮普无法安装LXML(Invalid re

2019-10-24 11:38发布

我有部署瓶应用到AWS EC2实例的问题。 可能与pip安装lxml 。 但我不知道如何解决这个问题。

AWS EC2:

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

从CLI对eb create

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)我没有这个错误。

Answer 1:

大概吧。

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

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

如果再次失败,有一个检查下列问题,他们只限于lxml安装问题有关:

  • 安装在python LXML模块
  • 如何在Ubuntu上安装LXML
  • PIP安装LXML错误


文章来源: Invalid requirements.txt on deploying to AWS. Pip couldn't install lxml