Because matplotlib needs numpy to already be installed, I have run into an issue.
因为matplotlib需要已经安装numpy,所以我遇到了一个问题。
To install other python packages on my Elastic Beanstalk environment, I use the pip requirements.txt file. Because the setup configuration automatically installs the packages in alphabetical order, matplotlib always is installed first which causes an error.
要在我的Elastic Beanstalk环境中安装其他python包,我使用pip requirements.txt文件。由于安装配置会按字母顺序自动安装软件包,因此始终首先安装matplotlib,这会导致错误。
Has anyone had this problem and know of a way to successfully fix it?
有没有人有这个问题,并知道成功修复它的方法?
1 个解决方案
#1
7
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.
这几天我一直在用头撞墙,但似乎如果你想使用requirements.txt文件安装matplotlib / scipy / scikit-learn,你需要一次做一个模块。
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.
我能够理解的是,在Elastic Beanstalk包之前,它没有安装在虚拟环境的site-packages目录中,直到它成功地通过整个requirements.txt文件。
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.
因此,例如,如果您尝试同时安装numpy和scipy,就像我一样,它会失败,因为scipy找不到某些numpy模块(具体来说是numpy.distutils.core)。 Numpy坐在/ opt / python / run / venv / build等待去,但是pip正在查看/opt/python/run/venv/lib/python2.6/site-packages并且找不到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.
您需要在requirements.txt文件中只使用numpy进行一次提交,然后将其推送到Elastic Beanstalk。如果成功,numpy模块将在正确的位置,然后您可以进行第二次提交,其中需求已更新为scipy或matplotlib。
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
注意.ebextensions中的配置文件,您需要列出所有依赖项。具体来说,你应该在.ebextensions / myapp.config的顶部
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.
如果你想scipy需要atlas-sse3-devel和lapack-devel,matplotlib需要libpng-devel,freetype-devel和zlib-devel。
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.
另一种方法是通过SSH连接到与Elastic Beanstalk上的应用程序关联的ec2实例,启动虚拟环境(source / opt / python / run / venv / bin / activate)并自行安装包。
#1
7
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.
这几天我一直在用头撞墙,但似乎如果你想使用requirements.txt文件安装matplotlib / scipy / scikit-learn,你需要一次做一个模块。
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.
我能够理解的是,在Elastic Beanstalk包之前,它没有安装在虚拟环境的site-packages目录中,直到它成功地通过整个requirements.txt文件。
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.
因此,例如,如果您尝试同时安装numpy和scipy,就像我一样,它会失败,因为scipy找不到某些numpy模块(具体来说是numpy.distutils.core)。 Numpy坐在/ opt / python / run / venv / build等待去,但是pip正在查看/opt/python/run/venv/lib/python2.6/site-packages并且找不到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.
您需要在requirements.txt文件中只使用numpy进行一次提交,然后将其推送到Elastic Beanstalk。如果成功,numpy模块将在正确的位置,然后您可以进行第二次提交,其中需求已更新为scipy或matplotlib。
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
注意.ebextensions中的配置文件,您需要列出所有依赖项。具体来说,你应该在.ebextensions / myapp.config的顶部
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.
如果你想scipy需要atlas-sse3-devel和lapack-devel,matplotlib需要libpng-devel,freetype-devel和zlib-devel。
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.
另一种方法是通过SSH连接到与Elastic Beanstalk上的应用程序关联的ec2实例,启动虚拟环境(source / opt / python / run / venv / bin / activate)并自行安装包。