Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Elastic Beanstalk failed to install Python package using requirements.txt Git Pip

I tried to deploy a Flask app on AWS Elastic Beanstalk using eb deploy but failed.

I have the requirements.txt under the app directory:

Flask==0.12.2
numpy==1.13.3
pandas==0.21.1
requests==2.18.4
scipy==1.0.0
Werkzeug==0.12.2
-e git+http://github.com/hensing/PyDDE#egg=PyDDE

And python.config file under .ebextensions directory:

packages:
  yum:
    git: []
    gcc-c++: []
    make: []

The error message is:

INFO: Environment update is starting.

INFO: Deploying new version to instance(s).

ERROR: Your requirements.txt is invalid. Snapshot your logs for details.

ERROR: [Instance: i-03e92fa3c58b6e010] Command failed on instance. Return code: 1 Output: (TRUNCATED)... )

File "/usr/lib64/python2.7/subprocess.py", line 541, 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 2.

Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-ac tivity.log using console or EB CLI.

INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

ERROR: Unsuccessful command execution on instance id(s) 'i-03e92fa3c58b6e010'. Aborting the operation.

ERROR: Failed to deploy application.

And /var/log/eb-activity.log shows:

2018-01-19 04:26:53,878 ERROR Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 2

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 541, in check_call

raise CalledProcessError(retcode, cmd)

CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requiremen ts.txt' returned non-zero exit status 2 (Executor::NonZeroExitStatus)

It seems like this issue is because of the -e git+ installation is not supported by AWS Elastic Beanstalk?

like image 258
Chris Yao Avatar asked Jan 19 '18 04:01

Chris Yao


People also ask

How do I get PIP in Python?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!

What is requirement TXT in Python?

The requirements. txt is a file listing all the dependencies for a specific Python project. It may also contain dependencies of dependencies, as discussed previously. The listed entries can be pinned or non-pinned.

How do I install text requirements?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file. This saves time and effort.


1 Answers

The problem has been resolved.

It was NOT because of installation of PyDDE.

The actual reason was that installation of Scipy requires > 40MB memory and the default EC2 instance, t1.micro, doesn't have enough memory to install it. It can be resolved by using a larger EC2 instance. I eventually go with t2.medium.

Also, to install Pandas, it requires gcc. I modified .ebextensions\[env_name].config file with this: (I'm using python 2.7, from: elasticbeanstalk gcc and python-devel installation)

packages:
  yum:
    git: []
    gcc-c++: []
    python27-devel: []
like image 194
Chris Yao Avatar answered Oct 10 '22 22:10

Chris Yao