Invalid requirements.txt on deploying to AWS. Pip couldn't install lxml - amazon-ec2

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:
Installing lxml module in python
How to install lxml on Ubuntu
pip install lxml error

Related

Failed building wheel for cymunk

Hi it seems like I'm unable to install cymunk. I get a fatal error C1083: Cannot open include file: 'alloca.h' when trying to build wheel for cymunk.
C:\Users\Jessy\kivent\venv>pip install git+git://github.com/kivy/cymunk.git
Collecting git+git://github.com/kivy/cymunk.git
Cloning git://github.com/kivy/cymunk.git to c:\users\jessy\appdata\local\temp\pip-req-build-774s6m7_
Running command git clone --filter=blob:none --quiet git://github.com/kivy/cymunk.git 'C:\Users\Jessy\AppData\Local\Temp\pip-req-build-774s6m7_'
Resolved git://github.com/kivy/cymunk.git to commit 24845cc0834cd07b9495d06ef3873252237c6714
Preparing metadata (setup.py) ... done
Building wheels for collected packages: cymunk
Building wheel for cymunk (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Using distutils
C:\Users\Jessy\AppData\Local\Programs\Python\Python310\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\Jessy\AppData\Local\Temp\pip-req-build-774s6m7_\cymunk\cymunk.pxd
tree = Parsing.p_module(s, pxd, full_module_name)
warning: cymunk\constraint.pxd:6:41: Declarations should not be declared inline.
warning: cymunk\space.pxd:23:4: 'cpTimestamp' redeclared
warning: cymunk\space.pxd:59:4: 'cpConstraintPreSolveFunc' redeclared
warning: cymunk\space.pxd:60:4: 'cpConstraintPostSolveFunc' redeclared
warning: cymunk\shape.pxi:204:86: local variable 'info' referenced before assignment
warning: cymunk\shape.pxi:205:54: local variable 'info' referenced before assignment
warning: cymunk\shape.pxi:205:62: local variable 'info' referenced before assignment
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
cl : Command line warning D9002 : ignoring unknown option '-ffast-math'
cl : Command line warning D9002 : ignoring unknown option '-fPIC'
chipmunk.c
C:\Users\Jessy\AppData\Local\Temp\pip-req-build-774s6m7_\cymunk\Chipmunk-Physics\include\chipmunk\chipmunk.h(36): fatal error C1083: Cannot open include file: 'alloca.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cymunk
Running setup.py clean for cymunk
Failed to build cymunk
Installing collected packages: cymunk
Running setup.py install for cymunk ... error
error: subprocess-exited-with-error
× Running setup.py install for cymunk did not run successfully.
│ exit code: 1
╰─> [9 lines of output]
Using distutils
C:\Users\Jessy\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
cl : Command line warning D9002 : ignoring unknown option '-ffast-math'
cl : Command line warning D9002 : ignoring unknown option '-fPIC'
chipmunk.c
C:\Users\Jessy\AppData\Local\Temp\pip-req-build-774s6m7_\cymunk\Chipmunk-Physics\include\chipmunk\chipmunk.h(36): fatal error C1083: Cannot open include file: 'alloca.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> cymunk
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
I tried with 'pipwin' and 'python setup.py build --compiler=mingw32'

Failed to build spherical-geometry. ERROR: Could not build wheels for spherical-geometry which use PEP 517 and cannot be installed directly

I am just trying to install package 'spherical-geometry with pip but failed. My python version is 3.8 in Mac OS system. And the pip is installed by anaconda3. Below I show the primary reported error. I am wondering how to solve this.
(base) ➜ Applications pip install spherical-geometry
Collecting spherical-geometry
Using cached spherical_geometry-1.2.19.tar.gz (9.2 MB)
Installing build dependencies ... done
Building wheels for collected packages: spherical-geometry
Building wheel for spherical-geometry (PEP 517) ... error
ERROR: Command errored out with exit status 1:
In file included from libqd/src/dd_const.cpp:11:
In file included from libqd/include/qd/dd_real.h:32:
...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:26: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:60: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:18: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:50: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:646:17: error: no template named 'numeric_limits'
static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
/private/var/folders/77/s1_49xgj7bv4gxjwsbfgbh8m0000gn/T/pip-build-env-rucjcqmx/overlay/lib/python3.8/site-packages/setuptools/dist.py:642: UserWarning: Usage of dash-separated 'upload-dir' will not be supported in future versions. Please use the underscore name 'upload_dir' instead
warnings.warn(
/private/var/folders/77/s1_49xgj7bv4gxjwsbfgbh8m0000gn/T/pip-build-env-rucjcqmx/overlay/lib/python3.8/site-packages/setuptools/dist.py:642: UserWarning: Usage of dash-separated 'show-response' will not be supported in future versions. Please use the underscore name 'show_response' instead
warnings.warn(
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for spherical-geometry
Failed to build spherical-geometry
ERROR: Could not build wheels for spherical-geometry which use PEP 517 and cannot be installed directly

unable to install ruby em-websocket: giving fatal error in Ubuntu 16.04

websocket via gem install em-websocket. Got this error:
compiling binder.cpp
cc1plus: warning: command line option ‘-Wimplicit-int’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++
In file included from binder.cpp:20:0:
project.h:25:20: fatal error: iostream: No such file or directory
compilation terminated.
Makefile:233: recipe for target 'binder.o' failed
make: *** [binder.o] Error 1
make failed, exit code 2
...
How to deal with this?
iostream was introduced in libstc++-6.Installing libstdc++6-4.4-dev by sudo apt-get install libstdc++6-4.4-dev. it will delete currently installed g++.Then run sudo apt-get install g++.This solved my problem.

Gcc Error Trying to PIP Install Fasttext Redhat (Amazon ec2)

Simply I am getting this error:
gcc: error: fasttext/fasttext.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 4
Trying to run command: sudo pip install fasttext
Server info:
NAME="Amazon Linux AMI"
VERSION="2016.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2016.09"
PRETTY_NAME="Amazon Linux AMI 2016.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2016.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2016.09

Openssl support for ruby not found in passenger installation on redhat 6

I have openssl 1.0.1e-42.el6 already installed. Also tried to compile openssl from ext/openssl directory which failed with below error
ossl_pkey_ec.c:815: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function)
ossl_pkey_ec.c:815: error: (Each undeclared identifier is reported only once
ossl_pkey_ec.c:815: error: for each function it appears in.)
make: *** [ossl_pkey_ec.o] Error 1
Is there any workaround for this problem ? or is this a compatibility problem with ruby 1.8.7-p358 and openssl 1.0.1e-42.el6. Due to this I am unable to install phusion passenger
Fixed the above issue by applying the patch.
Refer link https://bugs.ruby-lang.org/issues/8384
You have to download the out.patch file to ruby source ext/openssl folder and run patch < out.patch command. Then compile openssl

Resources