【问题标题】:opencv import issue and double installopencv 导入问题和双重安装
【发布时间】:2018-10-07 09:18:19
【问题描述】:

以前 ROS 安装在我的系统中,它需要 opencv 来实现,现在我正在使用 anaconda,我需要再次使用 opencv 库。在编写python代码时import cv2会抛出错误module not found

有没有办法使用 ROS 安装在 anaconda 中的那个 opencv 库

虽然我再次使用 conda 安装了 opencv。

$conda install -c conda-forge opencv 

然而 opencv-3.3 是使用上述命令安装的。现在我的 python 代码显示不同的导入错误,如下所示:

ImportError                               Traceback (most recent call last)
<ipython-input-9-6b49ad4d4ca5> in <module>()
      1 from random import shuffle
      2 import glob
----> 3 import cv2
      4 shuffle_data = True  # shuffle the addresses before saving
      5 hdf5_path = 'dataset.hdf5'  # address to where you want to save the hdf5 file

ImportError: /home/kamal/ros_catkin_ws/install_isolated/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

如何具体指定要使用的 opencv 库。我需要更改哪些环境变量。 任何帮助将不胜感激。

【问题讨论】:

标签: linux python-3.x opencv


【解决方案1】:

在 .bashrc 文件中取消注释 source /home/user/ros_catkin_ws/install_isolated/share/setup.bash 行没有帮助。还需要去掉ROS环境添加的extrasys.path。 在 python 控制台中

import sys
print (sys.path)

您将看到与 ROS 相关的多个路径 然后删除路径中不需要的部分

sys.path.remove('unwanted_path')

这将解决问题,但现在 ROS 将无法工作。要使其正常工作,您需要再次附加已删除的路径。 如果有人有更好的方法,请回答。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多