如果不再支持 OpenCV 2.4,如何安装? [英] How to install OpenCV 2.4 if it is no longer supported?

查看:209
本文介绍了如果不再支持 OpenCV 2.4,如何安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在此处运行此代码 https://github.com/feichtenhofer/gpu_flow/ 这要求我首先安装 OpenCV 2.4.但是当我尝试这样做时出现以下错误,我读到这意味着该版本不再受支持.那么如何安装 OpenCV 2.4 版?

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

推荐答案

请注意 OpenCV 2.x 已从 PyPI 中删除,因为将来会被弃用.您可以通过使用 pip 列出 opencv-python 的所有可能公式来解决这个问题:

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==

pip 上可用的最早版本是 3.4.您有什么特别的理由想要专门使用 OpenCV 2.4?

The earliest version available on pip is 3.4. Is there a particular reason why you want to specifically use OpenCV 2.4?

但是,如果您愿意这样做,我建议您访问通过 opencv-python 包实际上自动将 OpenCV 发布到 PyPI 的存储库:https://github.com/skvark/opencv-python

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

从这里开始,您必须手动自己构建包以生成可通过 pip 安装的轮子,然后自己安装.首先,您需要使用 git 来克隆存储库.接下来,您需要运行安装配置来构建 OpenCV 包并使用 2.4 版进行编译,然后将其安装到您的机器上.

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

以上确保了为 OpenCV 构建 Python 包所伴随的 OpenCV 源设置为版本 2.4.

The above ensures that the OpenCV source that accompanies the effort for building the Python package for OpenCV is set to version 2.4.

您必须稍等片刻才能构建.当它最终准备就绪时,您将在刚刚克隆的存储库中看到一个 dist 目录.打开它,您将看到一个 .whl 文件,您可以使用该文件通过 pip 在您的计算机上安装 OpenCV:

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

应该是构建的 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.

祝你好运!

附言我强烈建议您寻找另一个包或进行一些代码迁移以迁移到 OpenCV 3 或 4.这些较新版本中的重大改进在 OpenCV 2 中没有看到,有助于提高性能和可维护性.

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.

这篇关于如果不再支持 OpenCV 2.4,如何安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆