Reputation: 2412
I am trying to run this code here https://github.com/feichtenhofer/gpu_flow/ which requires me to first install OpenCV 2.4. But I get the error below when trying to do so and I read that this means the version is no longer supported. So how can I install OpenCV version 2.4?
user:~$ pip install opencv-python==2.4
WARNING: Keyring is skipped due to an exception: Failed to unlock the collection!
WARNING: Keyring is skipped due to an exception: Failed to unlock the collection!
ERROR: Could not find a version that satisfies the requirement opencv-python==2.4 (from versions: 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10, 3.3.1.11, 3.4.0.12, 3.4.0.14, 3.4.1.15, 3.4.2.16, 3.4.2.17, 3.4.3.18, 3.4.4.19, 3.4.5.20, 3.4.6.27, 3.4.7.28, 3.4.8.29, 3.4.9.31, 3.4.9.33, 4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25, 4.1.1.26, 4.1.2.30, 4.2.0.32, 4.2.0.34)
ERROR: No matching distribution found for opencv-python==2.4
Upvotes: 1
Views: 3266
Reputation: 104503
Please note that OpenCV 2.x has been removed from PyPI due to future deprecation. You can figure this out by listing out all possible formulae for opencv-python
using pip
:
$ pip install opencv-python==
ERROR: Could not find a version that satisfies the requirement opencv-python==
(from versions: 3.4.2.16, 3.4.2.17, 3.4.3.18, 3.4.4.19, 3.4.5.20, 3.4.6.27,
3.4.7.28, 3.4.8.29, 3.4.9.31, 3.4.9.33, 4.0.0.21, 4.0.1.24, 4.1.0.25, 4.1.1.26,
4.1.2.30, 4.2.0.32, 4.2.0.34)
ERROR: No matching distribution found for opencv-python==
The earliest version available on pip
is 3.4. Is there a particular reason why you want to specifically use OpenCV 2.4?
However, if it is your desire to do so, I would recommend visiting the repo that actually automatically releases OpenCV to PyPI through the opencv-python
package: https://github.com/skvark/opencv-python
From here, you must manually build the package yourself to generate a wheel installable through pip
then install it yourself. First you will need to use git
to clone the repo. Next, you will need to run the setup configuration to build the OpenCV package and compile it with version 2.4, then install it on your machine.
$ git clone --recursive https://github.com/skvark/opencv-python.git
$ cd opencv-python/opencv
$ git checkout 2.4
$ cd ..
$ python setup.py bdist_wheel
The above ensures that the OpenCV source that accompanies the effort for building the Python package for OpenCV is set to version 2.4.
You'll have to wait a bit for this to build. When it's finally ready, you will see a dist
directory in the repo you just cloned. Open this up and you'll see a .whl
file that you can use to install OpenCV on your computer via pip
:
$ cd dist
$ pip install <name of opencv 2.4>.whl
<name of opencv 2.4>
should be the filename of the OpenCV 2.4 wheel that was built. There should only be one file here with extension .whl
.
Good luck!
P.S. I would highly suggest you look for another package or do some code migrations to move to OpenCV 3 or 4. There have been substantial improvements in these newer versions that are not seen with OpenCV 2 that help with performance and maintainability.
Upvotes: 2