Tee*_*aps 9 django numpy matplotlib amazon-web-services amazon-elastic-beanstalk
因为matplotlib需要已经安装numpy,所以我遇到了一个问题.
要在我的Elastic Beanstalk环境中安装其他python包,我使用pip requirements.txt文件.由于安装配置会按字母顺序自动安装软件包,因此始终首先安装matplotlib,这会导致错误.
有没有人有这个问题,并知道成功修复它的方法?
这几天我一直在用头撞墙,但似乎如果你想使用requirements.txt文件安装matplotlib/scipy/scikit-learn,你需要一次做一个模块.
我能够理解的是,Elastic Beanstalk软件包没有安装在虚拟环境的site-packages目录中,直到它成功地完成了整个的requirements.txt文件.
因此,例如,如果您尝试同时安装numpy和scipy,就像我一样,它会失败,因为scipy无法找到某些numpy模块(具体来说是numpy.distutils.core).Numpy坐在/opt/python/run/venv/build等待着去,但是pip正在寻找/opt/python/run/venv/lib/python2.6/site-packages并且没有找到numpy.
您需要在requirements.txt文件中只使用numpy进行一次提交,然后将其推送到Elastic Beanstalk.如果这成功,numpy模块将在正确的位置,然后您可以进行第二次提交,其中需求已更新为scipy或matplotlib.
请注意.ebextensions中的配置文件,您需要列出所有依赖项.具体来说,.ebextensions/myapp.config你应该有顶部
packages:
yum:
gcc-c++: []
gcc-gfortran: []
python-devel: []
atlas-sse3-devel: []
lapack-devel: []
libpng-devel: []
freetype-devel: []
zlib-devel: []
Run Code Online (Sandbox Code Playgroud)
atlas-sse3-devel和lapack-devel需要,如果你想SciPy的和libpng-devel,freetype-devel以及zlib-devel需要为matplotlib.
另一种方法是通过SSH连接到与Elastic Beanstalk上的应用程序关联的ec2实例,启动虚拟环境(source /opt/python/run/venv/bin/activate)并自行安装包.