[Image Recognition] Solve the problem that the cv2 library cannot be installed, the most complete solution in the whole network! I personally tested it and summarized it by referring to stackoverflow, 51CTO and other blog articles

Scope of this article:故障排查 cv2 技术 库安装 Linux/Unix

Notebook system: win10
python version: 3.10
Fault problem: cv2 library cannot be installed
Adaptation objects: novice programmers, operation and maintenance programmers, college students, teenagers who are interested in the system, etc.


foreword

        With the popularization of electronic sky eyes, images have become more and more important, and our artificial intelligence society today will inevitably come into contact with some related content of image recognition. The related content of image recognition also appeared in the textbooks of junior high school children.


提示:以下是本篇文章正文内容,下面案例可供参考

1. What is the cv2 library?

        Example: cv2 is a tool based on opencv created to solve image processing tasks.

Two, a variety of solutions, see which one suits you! ! !

        First, the standard installation is as in method 1. For intractable diseases, see the solutions below.

1. (Normal, under normal circumstances) import library cv2, use cmd to install

The installation code is as follows:

pip install cv2

If you are python3, you can use the following code:

pip3 install cv2

2. (Insufficient permissions problem) Use super (administrator) Windows Powershell

        In the case that the above method fails and the folder is not writable, the solution is as follows:
not writable
PS Attention! ! ! : The interface is blue ! ! ! ! ! ! ! ! This is the file management system that you can accept the highest authority at present, under the win GUI environment.
admin cmd
The installation code is as follows:

pip install cv2

If you are python 3 , you can use the following code:

pip3 install cv2

3. (Version problem!!!) This needs to be done in a variety of ways

Method 1: Install pycharm and install it in the library management

pycharm

Method 2: If the above methods still do not work

        If the installation of the cv2 library still fails, then use the following. Of course, when installing the relevant library, you need to pay attention to whether the connection will time out. The three-layer handshake is sometimes long, so it is recommended to replace the domestic mirror source to solve related problems.
The installation code of the python2 version is as follows:

pip install opencv-python

The installation code for the python 3 version is as follows:

pip3 install opencv-python

Method 3: (End Scattered Flower Version) All problems can be solved by this method

        If you are lucky enough to miss all of the above methods, then use the method I propose below! This is what the blogger thinks. First of all, I reflect on why I can’t solve the relevant problems after reading so many blogs. Is there a mistake in my troubleshooting direction❌? not really! I thought about it later, and thought that I installed two versions of python3, the minor version is 8 and the minor version is 10, and I installed 38 in the professional version under certain circumstances, and I need to use it for work now It is 310, so this confuses our file management system and makes the file management system mistakenly think that we have installed the cv2 library (premise: the blogger’s version 3.8 has already installed the cv2 library) so all the problems Both point to my 3.10 being abandoned by the file management system. . .
        So I won’t talk too much nonsense at this time (to be honest, I’ve already said a lot, and I can’t solve it anymore, secretly charge me hahahaha!)
Code po:

py -3.10 -m pip install opencv-python

Here are the successful renderings:
Screenshot of successful installation


Summarize

        The above is what I want to talk about today. This article only briefly introduces various solutions to the failure of cv2 library installation. I hope that you can get what you want from it.

Guess you like

Origin blog.csdn.net/weixin_44568751/article/details/129731972