1

Problem

I am trying to install python packages that have C dependencies on AWS Elastic Beanstalk (namely : fbprophet and xgboost)

Elastic Beanstalk python installs packages from requirements.txt by default with pip or pipenv on Amazon Linux 2

However, fbprophet and xgboost have dependencies in C that need to be compiled before installing them with pip. conda comes with these libraries precompiled so they are a lot easier to install with conda.


What I have tried

Here is my attempt at installing them with conda using a .config file in .ebextensions folder :

commands:
  00_download_conda:
    command: 'wget http://repo.continuum.io/archive/Anaconda3-2020.02-Linux-x86_64.sh'
    test: test ! -d /anaconda
  01_install_conda:
    command: 'bash Anaconda3-2020.02-Linux-x86_64.sh -b -f -p /anaconda'
    test: test ! -d /anaconda
  02_reload_bash: 
    command: 'source ~/.bashrc'
  03_create_home:
    command: 'mkdir -p /home/wsgi'
  04_conda_env:
    command: 'conda env create -f environment.yml'
  05_activate_env:
    command: 'conda activate demo_forecast'

However this does not work and throws this error :

[2020-04-21T18:18:22.285Z] INFO  [3699]  - [Application update app-8acc-200421_201612@4/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_0_test_empty_dash/Command 03_conda_env] : Activity execution failed, because: /bin/sh: conda: command not found
   (ElasticBeanstalk::ExternalInvocationError)


[2020-04-21T18:18:22.285Z] INFO  [3699]  - [Application update app-8acc-200421_201612@4/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_0_test_empty_dash/Command 03_conda_env] : Activity failed.

So it seems that sourcing the .bashrc does not create the conda alias

I am aware of this question and its answer , however it is a little bit old and does not provide enough details for my case, because it does not go through with installing packages using conda.

Another way would be to try and install and compile the C dependencies before pip installing the requirement, but I had no success there for now.

Thank you for the help !

Luis Blanche
  • 557
  • 9
  • 18
  • Did you figure it out? I'm anticipating this same problem when I go to deploy in a few days. My ML model based Flask app is too big to work on Heroku so trying EBS. I'll update if anything works. – Kyle May 08 '20 at 13:16
  • I ended up using a workaround and installing the C dependancies before installing with pip – Luis Blanche May 14 '20 at 12:58

0 Answers0