python3 cv2模块,ImportError:没有名为“ cv2” Python3的模块

I have such a problem

(face_det) user@pc:~$ python3

Python 3.5.3 (default, Apr 22 2017, 00:00:00)

[GCC 4.8.4] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import cv2

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named 'cv2

I don't have it on python2:

(face_det) user@pc:~$ python2

Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

Anaconda is brought to you by Continuum Analytics.

Please check out: http://continuum.io/thanks and https://anaconda.org

>>> import cv2

>>>

In spite of the fact, that I have opencv (I've also tryed to remove it and install then):

(face_det) user@pc:~$ pip3 install opencv

Requirement already satisfied: opencv in ./.virtualenvs/face_det/lib/python3.5/site-packages

(face_det) user@pc:~$ conda install opencv

Fetching package metadata .........

Solving package specifications: .

# All requested packages already installed.

# packages in environment at /home/pc/anaconda3:

#

opencv 3.2.0 np112py27_0 conda-forge

解决方案

Try

pip3 install opencv-python

to get the cv2. I'm not sure when opencv-python became available. I'd been building opencv by hand, but when I looked a few weeks ago, there it was. I'm using cv2 with Python3 in a VM that's running ubuntu/trusty64.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您遇到的错误是因为在安装opencv4.5时找不到“libopencv_ml.so.3.4”这个共享对象文件。看起来您的系统缺少一些必要的依赖项。为了解决这个问题,您可以尝试以下方法: 1. 使用yum进行安装: 运行以下命令来安装所需的依赖项: ``` sudo yum install libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64 ``` 2. 重新安装opencv包: 首先,使用pip卸载opencv-python: ``` pip uninstall opencv-python ``` 然后,重新安装opencv-python-headless版本: ``` pip install opencv-python-headless ``` 3. 解决另一个错误: 您提到遇到了另一个错误“ImportError: libGL.so.1: cannot open shared object file: No such file or directory”。这个错误可能是由于缺少libGL.so.1这个共享对象文件导致的。您可以尝试通过安装以下软件包来解决这个问题: ``` sudo yum install mesa-libGL ``` 请按照上述步骤尝试解决您的问题,并确保您的系统中已经安装了必要的依赖项。这样应该能够解决“ImportError: libopencv_ml.so.3.4: cannot open shared object file: No such file or directory”的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ubuntu import cv2 报错 ImportError: libopencv_ml.so.4.0](https://blog.csdn.net/qq_43134830/article/details/115730423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [opencv ImportError: libGL.so.1: cannot open shared object file: No such file or directory](https://blog.csdn.net/guotianqing/article/details/115253263)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值