I have been beating my head against the wall with this for several days but it seems that if you want to install matplotlib/scipy/scikit-learn using a requirements.txt file you need to do things one module at a time.
What I have been able to understand is that on Elastic Beanstalk packages are not installed in the site-packages directory of the virtual environment until it has successfully worked its way through the entire requirements.txt file.
So for example if you try to install numpy and scipy at the same time, as I was doing, it will fail because scipy cannot find certain numpy modules (numpy.distutils.core specifically). Numpy is sitting in /opt/python/run/venv/build
waiting to go but pip is looking in /opt/python/run/venv/lib/python2.6/site-packages
and doesn't find numpy.
You need to make one commit with only numpy in your requirements.txt file and push this up to Elastic Beanstalk. If this succeeds the numpy module will be in the right place and then you can make a second commit with requirements updated to scipy or matplotlib in your case.
Be careful with your configuration file in .ebextensions, you need to have all the dependencies listed. Specifically, at the top of .ebextensions/myapp.config
you should have
packages:
yum:
gcc-c++: []
gcc-gfortran: []
python-devel: []
atlas-sse3-devel: []
lapack-devel: []
libpng-devel: []
freetype-devel: []
zlib-devel: []
atlas-sse3-devel
and lapack-devel
are needed if you want scipy and libpng-devel
, freetype-devel
, and zlib-devel
are needed for matplotlib.
The other alternative is to SSH to the ec2 instance associated with your app on Elastic Beanstalk, start up the virtual environment (source /opt/python/run/venv/bin/activate
) and pip install the packages yourself.