删除所有已安装的 OpenCV 库

发布于 2025-01-05 19:26:16 字数 2764 浏览 0 评论 0原文

我正在运行 Kubuntu 11.10 (w/ KDE 4.8)

在你阅读所有这些之前:

我只想从我的系统中删除 OpenCV 的所有痕迹,这样我就可以重新开始..

整个故事

我首先安装了 python-opencv 和 libopencv ( 2.1 我认为)来自 https://launchpad.net/~gijzelaar/+archive/opencv2 很久以前了。我当时只尝试过 python-opencv,它工作得很好(我没有尝试使用 OpenCV 来使用 C++ 代码)

然后我最近尝试从源代码安装 OpenCV 2.3.1,它已安装,但在编译我自己的 C++ 代码时(使用OpenCV),它给了我关于 libgtk 未安装的错误,并且还破坏了我之前运行良好的 python opencv 代码

所以我安装了 libgtk2-dev 库并再次编译并安装了 OpenCV 2.3.1..

错误仍然存​​在发生了,所以我删除了运行 cmake、make 等的解压 OpenCV 目录。我没有进行卸载(我现在意识到这是我的错误)

,而是从这里安装了 ubuntu opencv 2.3 软件包(包含所有依赖项): https://launchpad.net/~gijzelaar/+archive/opencv2.3

现在的问题是,当我编译 C++ 代码时,我仍然遇到相同的错误,其中包括OpenCV ,并且错误仍然指向我的(已删除的)OpenCV 源文件夹:

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/anant/opencv/OpenCV-2.3.1/modules/highgui/src/window.cpp, line 275
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/anant/opencv/OpenCV-2.3.1/modules/highgui/src/window.cpp:275: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

如您所见,错误仍然指向我编译和安装 OpenCV 的目录

有没有办法完全删除我编译的 OpenCV 版本的所有痕迹只保留 ubuntu 包中的文件?正如我之前提到的,我没有“进行卸载”,并且还(愚蠢地)删除了安装清单

编辑: 我再次运行包管理器,发现并非 ppa 中的所有 opencv 包都已正确安装。所以我再次执行了 sudo apt-get install opencv ,现在我收到此错误:

Unpacking libopencv2.3 (from .../libopencv2.3_2.3.1-3_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/libopencv2.3_2.3.1-3_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/libopencv_video.so.2.3.1', which is also in package libopencv-video2.3 2.3.1-4ppa1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Unpacking opencv (from .../opencv_2.3.1-3_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/opencv_2.3.1-3_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/opencv_haartraining', which is also in package libopencv-core-dev 2.3.1-4ppa1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libopencv2.3_2.3.1-3_amd64.deb
 /var/cache/apt/archives/opencv_2.3.1-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我只想从系统中删除 OpenCV 的所有痕迹,这样我就可以重新开始

I'm running Kubuntu 11.10 (w/ KDE 4.8)

Before you read all this :

I just want to remove all traces of OpenCV from my system, so I can start afresh..

The whole story

I first installed python-opencv and libopencv (2.1 I think) from https://launchpad.net/~gijzelaar/+archive/opencv2 a long time ago. I only tried python-opencv at that time, which worked perfectly (I didn't attempt using C++ code using OpenCV)

Then I recently tried to install OpenCV 2.3.1 from source, which got installed but while compiling my own C++ code (using OpenCV), it gave me errors about libgtk not installed and also broke my python opencv code which was running fine earlier

So I installed the libgtk2-dev libraries and compiled and installed OpenCV 2.3.1 again..

The error still occured, so I deleted the untarred OpenCV directory from which I was running cmake, make ,etc. I did NOT make uninstall (which I now realize was my mistake)

and instead installed the ubuntu opencv 2.3 package (with all dependencies) from here : https://launchpad.net/~gijzelaar/+archive/opencv2.3

Now the problem is I still get the same error when I compile my C++ code which includes OpenCV , and the error still points to my (deleted) OpenCV source folder :

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/anant/opencv/OpenCV-2.3.1/modules/highgui/src/window.cpp, line 275
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/anant/opencv/OpenCV-2.3.1/modules/highgui/src/window.cpp:275: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

As you can see the error still points to the directory from where I had compiled and installed OpenCV

Is there a way to completely remove all traces of my compiled version of OpenCV and just keep the files from the ubuntu package? As I mentioned earlier I did not 'make uninstall' and have also (foolishly) deleted the install-manifest

EDIT:
I ran the package manager again,and found that not all opencv packages from the ppa had gotten installed properly. So I did a sudo apt-get install opencv again, and now I get this error:

Unpacking libopencv2.3 (from .../libopencv2.3_2.3.1-3_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/libopencv2.3_2.3.1-3_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/libopencv_video.so.2.3.1', which is also in package libopencv-video2.3 2.3.1-4ppa1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Unpacking opencv (from .../opencv_2.3.1-3_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/opencv_2.3.1-3_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/opencv_haartraining', which is also in package libopencv-core-dev 2.3.1-4ppa1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libopencv2.3_2.3.1-3_amd64.deb
 /var/cache/apt/archives/opencv_2.3.1-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I just want to remove all traces of OpenCV from my system, so I can start afresh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

吃→可爱长大的 2025-01-12 19:26:16

默认情况下,当从源代码构建 OpenCV 时,它会将其输出放置在 /usr/local/lib/usr/local/bin 中。不过,从您的错误消息来看,它似乎将库放置在 /usr/lib 中,并将二进制文件放置在 /usr/bin 中,因此您也可以在那里签入。

您还可以使用 Linux find 命令。因此,要查找所有 OpenCV 库,您可以执行以下操作(这可能需要一段时间):

gt; sudo find / -name "*opencv*" -exec rm -i {} \;

上述命令将查找名称中包含 opencv 的任何文件,并提示您将其删除。一如既往,手动删除内容时要小心!

另一种选择可能是再次手动编译 OpenCV(完全,就像您之前所做的那样),make install 创建安装清单,然后尝试 < code>make uninstall 看看它是否会自行清理。

希望有帮助! :)

By default, when building OpenCV from source, it will place it's output in /usr/local/lib and /usr/local/bin. Although, judging from your error messages, it looks like it placed the libraries in /usr/lib and the binaries in /usr/bin, so you might also check in there.

You can also use the Linux find command. So, to find all OpenCV libraries you can do the following (this might take a while):

gt; sudo find / -name "*opencv*" -exec rm -i {} \;

The above command will find any file containing opencv in the name, and will prompt you to remove it. As always, be careful when deleting things manually!

Another option might be to manually compile OpenCV again (exactly as you did before), make install to create the install manifest, and then try make uninstall to see if it will clean up itself.

Hope that helps! :)

心房敞 2025-01-12 19:26:16

如果您有构建目录,则建议执行:

 $ sudo make uninstall

按照 @Navid 的回答从构建目录执行

但这会在某处留下一些 .so* 文件

要完全删除所有此类文件,请执行以下操作:

$ sudo rm /usr/local/{bin,lib}/*opencv* 

/usr/local 是我们在运行 cmake 时通常设置 CMAKE_INSTALL_PREFIX 的内容。根据您执行cmake的方式替换它

If you have the build directory then it is recommended to execute:

 $ sudo make uninstall

from the build directory as per @Navid 's answer

But this will leave few .so* files somewhere

To completely remove all such files, do:

$ sudo rm /usr/local/{bin,lib}/*opencv* 

/usr/local is what we normally set CMAKE_INSTALL_PREFIX to while running cmake. Replace it according to how you executed cmake

夏花。依旧 2025-01-12 19:26:16

您可以执行 sudo make uninstall 进行彻底卸载

You can do a sudo make uninstall for a clean uninstall

决绝 2025-01-12 19:26:16

我找不到构建目录,所以:

sudo apt-get purge '*opencv*'

和:

sudo find / -name "*opencv*" -exec rm -rf {} \;

这似乎工作得很好。

您可以使用以下命令仔细检查:

sudo find / -name "*opencv*";

I couldn't find the build directory so did:

sudo apt-get purge '*opencv*'

And:

sudo find / -name "*opencv*" -exec rm -rf {} \;

Which seems to have worked fine.

You can double check with:

sudo find / -name "*opencv*";

忆沫 2025-01-12 19:26:16

为了在没有“交互”的情况下删除所有文件和文件夹,请使用以下命令:

sudo find / -name "*opencv*" -exec rm -rf {} \;

警告:不建议运行“递归”和“强制”删除。

In order to remove all the files and folders without "interaction", use the below command :

sudo find / -name "*opencv*" -exec rm -rf {} \;

CAUTION: It's not advisable to run "recursive" and "force" deletion.

盛夏尉蓝 2025-01-12 19:26:16

如果在源代码上使用 sudo make install 命令安装 opencv,则转到构建文件夹并使用 sudo make uninstall ,它应该卸载 opencv

If opencv is installed using sudo make install command on source then go to the build folder and use sudo make uninstall and it should uninstall opencv

萌吟 2025-01-12 19:26:16

对于特定版本,例如 3.2:

sudo find / -name "*opencv*3.2*"   -exec rm -rf {} \;

for a specific version for example 3.2:

sudo find / -name "*opencv*3.2*"   -exec rm -rf {} \;
人心善变 2025-01-12 19:26:16
sudo rm /home/god/softwares/miniconda3/{bin,lib}/*opencv* 
sudo rm /home/god/softwares/miniconda3/{bin,lib}/*opencv* 
成熟稳重的好男人 2025-01-12 19:26:16

系统使用的一些文件和文件夹的名称中包含“opencv”。您绝对不想想要删除它们。所以我建议反对使用 $ sudo find / -name "*opencv*" -exec rm -rf {} \; 删除 opencv,因为它会递归删除所有文件并且名称中包含“opencv”的文件夹。

更好的替代方法是使用此命令,它会在删除找到的每个文件和文件夹之前提示您:

$ sudo find / -name "*opencv*" -exec rm -i {} \;

如果您不小心删除了系统的任何本机 opencv 文件并破坏了某些内容(或者可能当时看起来是个好主意),请执行以下修复:

  1. 删除已安装的 opencv 库
$ sudo apt remove libopencv-dev   
$ sudo apt remove libopencv-core3.2
  1. 但是,opencv-data 可能不被删除有了这个。您可以使用以下命令找到其余文件:

$ sudo apt list --installed | grep opencv

  1. 之后,使用 ROS Melodic 重新安装系统 opencv 文件:

$ sudo apt install ros-melodic-desktop-full

注意:如果您需要在安装 ros 之前设置源列表melodic,您可以使用以下命令(如果步骤 3 不适合您,请在步骤 3 之前执行它们):

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

$ sudo apt-get update

$ sudo apt-get install ros-melodic-desktop-full

There are some files and folders used by the system containing "opencv" in their name. You definitely do not want to remove them. So I advise against using $ sudo find / -name "*opencv*" -exec rm -rf {} \; to remove opencv, because it recursively deletes all files and folders containing "opencv" in their name.

A better alternative would be to use this command, which prompts you before deleting each of the files and folders found:

$ sudo find / -name "*opencv*" -exec rm -i {} \;

In case you accidentally removed any of the system's native opencv files and broke something (or maybe it seemed like a good idea at the time), here's your fix:

  1. Remove installed opencv libraries
$ sudo apt remove libopencv-dev   
$ sudo apt remove libopencv-core3.2
  1. However, opencv-data might not be removed with this. You can find the remaining files with this:

$ sudo apt list --installed | grep opencv

  1. After that, reinstall the system opencv files with ROS Melodic:

$ sudo apt install ros-melodic-desktop-full

N.B. If you need to set up the source list prior to installing ros melodic, you can use the commands below (execute them before step 3 if step 3 doesn't work for you):

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

$ sudo apt-get update

$ sudo apt-get install ros-melodic-desktop-full
も让我眼熟你 2025-01-12 19:26:16

我使用 mevatron linux 命令并遇到了 $HOME/opencv/ 中的文件和$HOME/opencv_contrib/ 也被删除。我推荐以下修改版本:

sudo find /usr -name "*opencv*" -exec rm -rI {} \;

-rI 是为了避免无休止的提示请求许可并删除目录。

I used mevatron linux command and encountered a problem that the files in $HOME/opencv/ and $HOME/opencv_contrib/ also got deleted. I recommand the following modified version:

sudo find /usr -name "*opencv*" -exec rm -rI {} \;

The -rI is to avoid the endless prompt asking for permission and delete directory as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文