1

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.

1 Answer 1

0

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.