删除所有已安装的 OpenCV 库
我正在运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
默认情况下,当从源代码构建 OpenCV 时,它会将其输出放置在
/usr/local/lib
和/usr/local/bin
中。不过,从您的错误消息来看,它似乎将库放置在/usr/lib
中,并将二进制文件放置在/usr/bin
中,因此您也可以在那里签入。您还可以使用 Linux find 命令。因此,要查找所有 OpenCV 库,您可以执行以下操作(这可能需要一段时间):
上述命令将查找名称中包含 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):
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 trymake uninstall
to see if it will clean up itself.Hope that helps! :)
如果您有构建目录,则建议执行:
按照 @Navid 的回答从构建目录执行
但这会在某处留下一些 .so* 文件
要完全删除所有此类文件,请执行以下操作:
/usr/local
是我们在运行cmake
时通常设置CMAKE_INSTALL_PREFIX
的内容。根据您执行cmake
的方式替换它If you have the build directory then it is recommended to execute:
from the build directory as per @Navid 's answer
But this will leave few .so* files somewhere
To completely remove all such files, do:
/usr/local
is what we normally setCMAKE_INSTALL_PREFIX
to while runningcmake
. Replace it according to how you executedcmake
您可以执行
sudo make uninstall
进行彻底卸载You can do a
sudo make uninstall
for a clean uninstall我找不到构建目录,所以:
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*";
为了在没有“交互”的情况下删除所有文件和文件夹,请使用以下命令:
警告:不建议运行“递归”和“强制”删除。
In order to remove all the files and folders without "interaction", use the below command :
CAUTION: It's not advisable to run "recursive" and "force" deletion.
如果在源代码上使用 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 usesudo make uninstall
and it should uninstall opencv对于特定版本,例如 3.2:
for a specific version for example 3.2:
系统使用的一些文件和文件夹的名称中包含“opencv”。您绝对不想想要删除它们。所以我建议反对使用
$ sudo find / -name "*opencv*" -exec rm -rf {} \;
删除 opencv,因为它会递归删除所有文件并且名称中包含“opencv”的文件夹。更好的替代方法是使用此命令,它会在删除找到的每个文件和文件夹之前提示您:
$ sudo find / -name "*opencv*" -exec rm -i {} \;
如果您不小心删除了系统的任何本机 opencv 文件并破坏了某些内容(或者可能当时看起来是个好主意),请执行以下修复:
opencv-data
可能不被删除有了这个。您可以使用以下命令找到其余文件:$ sudo apt list --installed | grep opencv
$ sudo apt install ros-melodic-desktop-full
注意:如果您需要在安装 ros 之前设置源列表melodic,您可以使用以下命令(如果步骤 3 不适合您,请在步骤 3 之前执行它们):
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:
opencv-data
might not be removed with this. You can find the remaining files with this:$ sudo apt list --installed | grep opencv
$ 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):
我使用 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.