How to install opencv-python on Amazon Elastic Bea

2019-06-24 01:25发布

问题:

I've been developing a Python application locally, and now want to deploy it to Amazon Elastic Beanstalk, but I have hit the following error:

Downloading/unpacking opencv-python==2.4.8.1 (from -r
/opt/python/ondeck/app/requirements.txt (line 12))  
Could not find any downloads that satisfy the requirement opencv-python==2.4.8.1
(from -r /opt/python/ondeck/app/requirements.txt (line 12))

Some externally hosted files were ignored (use --allow-external opencv-python to allow). 
Cleaning up... No distributions at all found for opencv-python==2.4.8.1 
(from -r /opt/python/ondeck/app/requirements.txt (line 12))

If I connect with SSH and type sudo pip install opencv-python it says "Downloading/unpacking opencv-python" for a minute or so, then:

Could not find any downloads that satisfy the requirement opencv-python
Cleaning up...
No distributions at all found for opencv-python
Storing debug log for failure in /root/.pip/pip.log

I also tried adding "http://rpmfind.net/linux/fedora/linux/development/rawhide/x86_64/os/Packages/o/opencv-python-2.4.9-3.fc22.x86_64.rpm" to my requirements.txt but that failed as follows:

Downloading/unpacking http://rpmfind.net/linux/fedora/linux/development/rawhide/x86_64/os/Packages/o/opencv-python-2.4.9-3.fc22.x86_64.rpm (from -r /opt/python/ondeck/app/requirements.txt (line 14))
  Cannot unpack file /tmp/pip-ONBFer-unpack/opencv-python-2.4.9-3.fc22.x86_64.rpm (downloaded from /tmp/pip-SUUfnS-build, content-type: application/x-rpm); cannot detect archive format
Cleaning up...
Cannot determine archive format of /tmp/pip-SUUfnS-build
Storing debug log for failure in /root/.pip/pip.log

I also tried "sudo yum install opencv-python" but that failed as follows:

Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/2014.09                                        | 2.1 kB     00:00
amzn-updates/2014.09                                     | 2.3 kB     00:00
No package opencv-python available.
Error: Nothing to do

For my development system I got the installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. How can I get it installed on EB, please?

If there's no way to install this exact package, what is the best alternative, please?

回答1:

Here are some options if you are able to consider workarounds.

With AWS Elastic Beanstalk

  • AWS EB supports Windows Server 2012 and 2008

    Since your installer appears to be a Windows executable, you might consider deploying on Windows. https://aws.amazon.com/net/

  • Use Docker to package Fedora platform to run on EB's AMI Linux host.

    Elastic Beanstalk supports Docker.
    http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.html

    Here is an example of a Docker buildfile for opencv on python. https://registry.hub.docker.com/u/ibotdotout/python-opencv/

Without AWS Elastic Beanstalk

  • Other Linux distribution

    If you don't absolutely require Elastic Beanstalk, what about running Fedora? These installation instructions are straightforward.

    http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.html (basically yum install numpy opencv* )

    You can use EC2 without Elastic Beanstalk.



回答2:

The easy workaround for now, is to install pip 1.2.1, which does not require SSL:

curl -O https://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz
tar xvfz pip-1.2.1.tar.gz
cd pip-1.2.1
python setup.py install

Maybe that can help you



回答3:

I am running OpenCV with Python support on Amazon EC2 on dedicated instances of Ubuntu 14.04. I had to install and compile from source to get a reliable stack with python.