Как удалить opencv python на windows

I have tried to install OpenCV in anaconda. but when I use it, I figure out the instead of using OpenCV, the program using OpenCV-python and that why my program crashed. I type "conda uninstall ope...

I have tried to install OpenCV in anaconda. but when I use it, I figure out the instead of using OpenCV, the program using OpenCV-python and that why my program crashed.
I type «conda uninstall opencv» but it just uninstalls OpenCV package not OpenCV-python. I also use » conda uninstall opencv-python» and «pip uninstall opencv-python» but it’s not work.

enter image description here

asked Jan 3, 2018 at 6:53

Lê Huy Hùng's user avatar

@Lê Huy Hùng

Please check official documentations before posting a question like this.

Here’s the official documentation of pip uninstall

Here’s how I uninstalled it

pip uninstall opencv-python

Uninstalling opencv-python-3.4.0.12:
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/QtCore
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/QtGui
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/QtTest
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libavcodec.57.107.100.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libavformat.57.83.100.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libavresample.3.7.0.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libmp3lame.0.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libswresample.2.9.100.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libswscale.4.8.100.dylib
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/LICENSE-3RD-PARTY.txt
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/LICENSE.txt
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/init.py
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/pycache/init.cpython-35.pyc
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/cv2.cpython-35m-darwin.so
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/init.py
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/pycache/init.cpython-35.pyc
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_eye.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_eye_tree_eyeglasses.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalcatface.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalcatface_extended.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalface_alt.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalface_alt2.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalface_alt_tree.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalface_default.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_fullbody.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_lefteye_2splits.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_licence_plate_rus_16stages.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_lowerbody.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_profileface.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_righteye_2splits.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_russian_plate_number.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_smile.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_upperbody.xml
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/DESCRIPTION.rst
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/INSTALLER
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/METADATA
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/RECORD
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/WHEEL
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/metadata.json
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/top_level.txt
Proceed (y/n)?
y
Successfully uninstalled opencv-python-3.4.0.12

Community's user avatar

answered Mar 26, 2018 at 5:16

Santhosh's user avatar

SanthoshSanthosh

1,5241 gold badge11 silver badges18 bronze badges

To uninstall I used this line of code and it worked,

    sudo pip uninstall opencv-python

Resulted as given:

Uninstalling opencv-python-4.0.0.21:   Would remove:

    c:program filesanaconda3libsite-packagescv2*
    c:program filesanaconda3libsite-packagesopencv_python-4.0.0.21.dist-info* Proceed (y/n)? y   Successfully uninstalled opencv-python-4.0.0.21

Chandan Gupta's user avatar

answered Feb 5, 2019 at 18:16

Developer Here's user avatar

1

  1. Go to directory where pip is installing your packages.
  2. You should able to see the egg file that corresponds to the package you want to uninstall. Delete the egg file (or, to be on the safe side, move it to a different directory).
  3. Do the same with the package files for the package you want to delete for (opencv-python)

answered Jan 3, 2018 at 7:02

Prem's user avatar

PremPrem

1,1787 silver badges13 bronze badges

2

According to official documentation, this issue must be solved quite easily:

pip uninstall opencv-python

answered Aug 27, 2019 at 0:39

Scott's user avatar

ScottScott

4,4476 gold badges32 silver badges58 bronze badges

I run the following code at the terminal: pip uninstall opencv-python. It works really well.
You can see the:
captured screen

answered Jul 23, 2020 at 12:43

Al hamdulillah's user avatar

1

1. pip — Python 2.x

[email protected]:~$ pip list | grep opencv
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
opencv-python                      3.4.1.15   
[email protected]:~$ 

2. pip3 — Python 3.x

[email protected]:~$ pip3 list | grep opencv
opencv-contrib-python (3.3.0.10)
opencv-python (3.4.0.12)
[email protected]:~$ 

3. Uninstall opencv-contrib-python

sudo pip3 uninstall opencv-contrib-python==3.3.0.10

[email protected]:~$ sudo pip3 uninstall opencv-contrib-python==3.3.0.10
[sudo] password for strong: 
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling opencv-contrib-python-3.3.0.10:
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libQtCore-ba1dc80c.so.4.8.7
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libQtGui-6d0f14dd.so.4.8.7
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libQtTest-1183da5d.so.4.8.7
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libz-a147dcb0.so.1.2.3
  /usr/local/lib/python3.5/dist-packages/cv2/LICENSE-3RD-PARTY.txt
  /usr/local/lib/python3.5/dist-packages/cv2/LICENSE.txt
  /usr/local/lib/python3.5/dist-packages/cv2/__init__.py
  /usr/local/lib/python3.5/dist-packages/cv2/__pycache__/__init__.cpython-35.pyc
  /usr/local/lib/python3.5/dist-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/DESCRIPTION.rst
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/INSTALLER
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/METADATA
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/RECORD
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/WHEEL
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/metadata.json
  /usr/local/lib/python3.5/dist-packages/opencv_contrib_python-3.3.0.10.dist-info/top_level.txt
Proceed (y/n)? y
  Successfully uninstalled opencv-contrib-python-3.3.0.10
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
[email protected]:~$ 

4. Uninstall opencv-python

sudo pip3 uninstall opencv-python==3.4.0.12

[email protected]:~$ sudo pip3 uninstall opencv-python==3.4.0.12
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling opencv-python-3.4.0.12:
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libavcodec-7625dabe.so.58.6.103
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libavformat-d3ca1b40.so.58.3.100
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libavutil-eaec640f.so.56.5.100
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libswresample-81cb7b3e.so.3.0.101
  /usr/local/lib/python3.5/dist-packages/cv2/.libs/libswscale-bc8d848b.so.5.0.101
  /usr/local/lib/python3.5/dist-packages/cv2/data/__init__.py
  /usr/local/lib/python3.5/dist-packages/cv2/data/__pycache__/__init__.cpython-35.pyc
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_eye.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_eye_tree_eyeglasses.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_frontalcatface.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_frontalcatface_extended.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_frontalface_alt.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_frontalface_alt2.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_frontalface_alt_tree.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_frontalface_default.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_fullbody.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_lefteye_2splits.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_licence_plate_rus_16stages.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_lowerbody.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_profileface.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_righteye_2splits.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_russian_plate_number.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_smile.xml
  /usr/local/lib/python3.5/dist-packages/cv2/data/haarcascade_upperbody.xml
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/DESCRIPTION.rst
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/INSTALLER
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/METADATA
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/RECORD
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/WHEEL
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/metadata.json
  /usr/local/lib/python3.5/dist-packages/opencv_python-3.4.0.12.dist-info/top_level.txt
Proceed (y/n)? y
  Successfully uninstalled opencv-python-3.4.0.12
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
[email protected]:~$

5. pip3 list | grep opencv

[email protected]:~$ pip3 list | grep opencv
[email protected]:~$ 

Время прочтения
7 мин

Просмотры 31K

Введение

В данной статье речь пойдет о сборке и установке OpenCV 4 для C/C++, Python 2 и Python 3 из исходных файлов с дополнительными модулями CUDA 10 на ОС Windows.

Я постарался включить сюда все тонкости и нюансы, с которыми можно столкнуться в ходе установки, и про которые не написано в официальном мануале.

Сборка тестировалась для:

  • Windows 8.1 + Visual Studio 2017 + Python 2/3 + CUDA 10.0 + GeForce 840m
  • Windows 10 + Visual Studio 2019 + Python 2/3 + CUDA 10.0 + GeForce GTX 1060

Внимание! Сборка не подойдет для версии OpenCV 4.0.1 и/или CUDA ниже 10-й версии. CUDA 9 и ниже поддерживается OpenCV 3.

Что потребуется для установки

В моей сборке использовались следующие инструменты:

  1. CMake 3.15
  2. MS Visual Studio 2019 64-бит + средства CMake С++ для Windows
  3. Python 3.7.3 64-бит + NumPy 64-бит
  4. Python 2.7.16 64-бит + NumPy 64-бит
  5. CUDA 10.0
  6. CuDNN 7.6.2
  7. OpenCV 4.1.1 и OpenCV-contrib-4.1.1

Установка

Так как установка производится через консольные команды, то следует внимательно и аккуратно выполнять все шаги. Также, при необходимости, меняйте установочные пути на свои.
Для начала необходимо установить требуемое ПО, причем Visual Studio должна быть установлена до CUDA:

  • CMake (версия >= 3.9.1)
  • MS Visual Studio
  • Python 3.7 (дистрибутив Anaconda3)
  • CUDA 10.0
  • CuDNN 7.6.2

После установки всех компонент убедитесь, что пути для CMake, Visual Studio, Python, CUDA, CuDNN прописаны в переменных PATH, PYTHONPATH, CUDA_PATH и cudnn соответственно.

Далее загружаем архивы исходников opencv-4.1.1 и opencv-contrib-4.1.1 в желаемое место (в моем случае это C:OpenCV).

git clone https://github.com/opencv/opencv.git -b "4.1.1"
git clone https://github.com/opencv/opencv_contrib.git -b "4.1.1"

Создаем папку build/ внутри opencv-4.1.1.

Далее сгенерируем файлы сборки с помощью cmake. Мы будем использовать консольный вариант cmake, так как cmake-gui путает типы некоторых переменных (например, OPENCV_PYTHON3_VERSION) и, как следствие, неправильно генерирует файлы.

Открываем консоль по пути C:OpenCV и прописываем переменные.

set "opencvSource=opencv-4.1.1"
set "opencvExtraModules=opencv_contrib-4.1.1/modules"
set "opencvBuild=%opencvSource%build"
set "compiler=Visual Studio 16 2019"
set "buildType=Release"

Примечание. Для Visual Studio 2017 генератор пишется как «Visual Studio 15 2017 Win64» и без флага -A.

Также можно явно указать питоновские библиотеки для python 2 и python 3 на случай, если сборщик не сможет найти их автоматически.

set "python2_executable=C:/Python27/python.exe"
set "python2_include_dir=C:/Python27/include"
set "python2_library=C:/Python27/libs/python27.lib"
set "python2_numpy_include_dirs=C:/Python27/Lib/site-packages/numpy/core/include"
set "python2_packages_path=C:/Python27/Lib/site-packages"

set "python3_executable=C:/Users/root/Anaconda3/python.exe"
set "python3_include_dir=C:/Users/root/Anaconda3/include"
set "python3_library=C:/Users/root/Anaconda3/libs/python37.lib"
set "python3_numpy_include_dirs=C:/Users/root/Anaconda3/lib/site-packages/numpy/core/include"
set "python3_packages_path=C:/Users/root/Anaconda3/Lib/site-packages"

Примечание. Обратите внимание на то, что библиотека NumPy должна быть той же разрядности, что и OpenCV. Проверить это легко:

import numpy.distutils.system_info as sysinfo
print(sysinfo.platform_bits)

Выполняем генерацию файлов сборки с помощью длинной команды ниже. При неудачной генерации или наличии ошибок после выполнения команды, повторную генерацию следует производить вычистив все файлы в build/ и .cache/.

cmake ^
-B"%opencvBuild%/" ^
-H"%opencvSource%/" ^
-G"%compiler%" ^
-Ax64 ^
-DCMAKE_BUILD_TYPE=%buildType% ^
-DBUILD_opencv_world=ON ^
-DINSTALL_TESTS=OFF ^
-DINSTALL_C_EXAMPLES=OFF ^
-DBUILD_EXAMPLES=OFF ^
-DOPENCV_EXTRA_MODULES_PATH="%opencvExtraModules%/" ^
-DBUILD_PROTOBUF=ON ^
-DBUILD_opencv_python_bindings_generator=ON ^
-DWITH_CUDA=ON ^
-DCUDA_FAST_MATH=ON ^
-DWITH_CUBLAS=ON ^
-DCUDA_ARCH_PTX=7.5 ^
-DBUILD_opencv_python2=ON ^
-DPYTHON2_EXECUTABLE="%python2_executable%" ^
-DOPENCV_PYTHON2_VERSION=2.7.16 ^
-DPYTHON2_INCLUDE_DIR="%python2_include_dir%" ^
-DPYTHON2_LIBRARY="%python2_library%" ^
-DPYTHON2_NUMPY_INCLUDE_DIRS="%python2_numpy_include_dirs%" ^
-DPYTHON2_PACKAGES_PATH="%python2_packages_path%" ^
-DBUILD_opencv_python3=ON ^
-DPYTHON3_EXECUTABLE="%python3_executable%" ^
-DOPENCV_PYTHON3_VERSION=3.7.3 ^
-DPYTHON3_INCLUDE_DIR="%python3_include_dir%" ^
-DPYTHON3_LIBRARY="%python3_library%" ^
-DPYTHON3_NUMPY_INCLUDE_DIRS="%python3_numpy_include_dirs%" ^
-DPYTHON3_PACKAGES_PATH="%python3_packages_path%"

Значение некоторых флагов

  • BUILD_opencv_world – необязательный модуль, содержащий копии всех выбранных в ходе установки библиотек. Удобен при разработке на C++, так как вместо подключения кучи зависимостей opencv можно подключить одну зависимость opencv_world411.lib в проект
  • INSTALL_EXAMPLES/INSTALL_TESTS – установка примеров/тестов кода opencv
  • CUDA_FAST_MATH, WITH_CUBLAS – дополнительные модули для CUDA, призванные ускорить вычисления
  • CUDA_ARCH_PTX – версия PTX инструкций для улучшения производительности вычислений
  • OPENCV_EXTRA_MODULES_PATH – путь до дополнительных модулей из opencv-contrib (обязательно для CUDA)
  • BUILD_PROTOBUF – для работы некоторых модулей opencv необходим Protobuf (сборщик opencv в любом случае поставит BUILD_PROTOBUF=ON)

Спустя примерно 10 минут в консоле должна появиться информация о сборке и завершающие строки «Configuring done» и «Generating done». Проверяем всю информацию, особенно разделы NVIDIA CUDA, Python 2, Python 3.

Далее собираем решение. На сборку может уйти несколько часов в зависимости от вашего процессора и версии Visual Studio.

cmake --build %opencvBuild% --target ALL_BUILD --config Release

Устанавливаем решение.

cmake --build %opencvBuild% --target INSTALL --config Release

После успешной установки создаем системную переменную OPENCV_DIR со значением C:OpenCVopencv-4.1.1buildinstallx64vc15bin и также добавляем ее в PATH.

Тест

Проверим работоспособность OpenCV с модулем CUDA на простом примере умножения матриц.

Подключение OpenCV в проект Visual Studio

  1. Установить тип сборки Release/x64 (для Debug следует собрать OpenCV с флагом Debug)
  2. Project Properties → C/C++ → General → Добавить строку «C:OpenCVopencv-4.1.1buildinstallinclude» в Additional Include Directories
  3. Project Properties → Linker → General → Добавить строку « C:OpenCVopencv-4.1.1buildinstallx64vc16lib» в Additional Library Directories
  4. Project Properties → Linker → General → Добавить «;opencv_world411.lib» («;opencv_world411d.lib» для Debug) в конец Additional Dependencies

Пример на Python 3

import numpy as np
import cv2 as cv
import time

rand = np.random.random((1024, 1024)).astype(np.float32)
h_array1 = np.stack([rand, rand],axis=2)
h_array2 = h_array1
d_array1 = cv.cuda_GpuMat()
d_array2 = cv.cuda_GpuMat()
d_array1.upload(h_array1)
d_array2.upload(h_array2)

start = time.time()
cv.cuda.gemm(d_array1, d_array2, 1, None, 0, None, 1)
end = time.time()
print("Time elapsed:", end - start, "sec")

Вывод в консоли

Time elapsed: 0.3130002021789551

Пример на C++

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/cudaarithm.hpp>

using namespace std;
using namespace cv;
using namespace cv::cuda;

int main() {

	Mat h_array1 = Mat::ones(1024, 1024, CV_32FC2);
	Mat h_array2 = Mat::ones(1024, 1024, CV_32FC2);
	Mat h_array3 = Mat::zeros(1024, 1024, CV_32FC2);
	Mat h_result;
	GpuMat d_array1, d_array2, d_array3, d_result;

	d_array1.upload(h_array1);
	d_array2.upload(h_array2);

	const clock_t begin_time = clock();
	cuda::gemm(d_array1, d_array2, 1.0, d_array3, 0.0, d_result);
	cout << "Time elapsed: " << (float(clock() - begin_time) / CLOCKS_PER_SEC) << " sec" << endl;

	d_result.download(h_result);

	return 0;
}

Вывод в консоли

Time elapsed: 0.354

Удаление

Чтобы удалить OpenCV, нужно выполнить команду.

cmake --build %opencvBuild% --target uninstall --config Release

и удалить системную переменную OPENCV_DIR и убрать путь до OpenCV из PATH.

Заключение

В статье мы рассмотрели установку OpenCV 4 для ОС Windows 10. Данный алгоритм тестировался на Windows 8.1 и Windows 10, но, в теории, может собираться и на Windows 7. За дополнительной информацией можно обратиться к списку источников ниже.

P.S. Напоследок сведем все установочные команды в один .bat файл для тех, кто хочет автоматизировать установку.

install_opencv411.bat

cd C:OpenCV

git clone https://github.com/opencv/opencv_contrib.git -b "4.1.1"
git clone https://github.com/opencv/opencv.git -b "4.1.1"

ren opencv opencv-4.1.1
ren opencv_contrib-4.1.1

set "opencvSource=opencv-4.1.1"
set "opencvExtraModules=opencv_contrib-4.1.1/modules"
set "opencvBuild=%opencvSource%build"
set "compiler=Visual Studio 16 2019"
set "buildType=Release"

set "python2_executable=C:/Python27/python.exe"
set "python2_include_dir=C:/Python27/include"
set "python2_library=C:/Python27/libs/python27.lib"
set "python2_numpy_include_dirs=C:/Python27/Lib/site-packages/numpy/core/include"
set "python2_packages_path=C:/Python27/Lib/site-packages"

set "python3_executable=C:/Users/root/Anaconda3/python.exe"
set "python3_include_dir=C:/Users/root/Anaconda3/include"
set "python3_library=C:/Users/root/Anaconda3/libs/python37.lib"
set "python3_numpy_include_dirs=C:/Users/root/Anaconda3/lib/site-packages/numpy/core/include"
set "python3_packages_path=C:/Users/root/Anaconda3/Lib/site-packages"

cmake ^
-B"%opencvBuild%/" ^
-H"%opencvSource%/" ^
-G"%compiler%" ^
-Ax64 ^
-DCMAKE_BUILD_TYPE=%buildType% ^
-DBUILD_opencv_world=ON ^
-DINSTALL_TESTS=OFF ^
-DINSTALL_C_EXAMPLES=OFF ^
-DBUILD_EXAMPLES=OFF ^
-DOPENCV_EXTRA_MODULES_PATH="%opencvExtraModules%/" ^
-DBUILD_PROTOBUF=ON ^
-DBUILD_opencv_python_bindings_generator=ON ^
-DWITH_CUDA=ON ^
-DCUDA_FAST_MATH=ON ^
-DWITH_CUBLAS=ON ^
-DCUDA_ARCH_PTX=7.5 ^
-DBUILD_opencv_python2=ON ^
-DPYTHON2_EXECUTABLE="%python2_executable%" ^
-DOPENCV_PYTHON2_VERSION=2.7.16 ^
-DPYTHON2_INCLUDE_DIR="%python2_include_dir%" ^
-DPYTHON2_LIBRARY="%python2_library%" ^
-DPYTHON2_NUMPY_INCLUDE_DIRS="%python2_numpy_include_dirs%" ^
-DPYTHON2_PACKAGES_PATH="%python2_packages_path%" ^
-DBUILD_opencv_python3=ON ^
-DPYTHON3_EXECUTABLE="%python3_executable%" ^
-DOPENCV_PYTHON3_VERSION=3.7.3 ^
-DPYTHON3_INCLUDE_DIR="%python3_include_dir%" ^
-DPYTHON3_LIBRARY="%python3_library%" ^
-DPYTHON3_NUMPY_INCLUDE_DIRS="%python3_numpy_include_dirs%" ^
-DPYTHON3_PACKAGES_PATH="%python3_packages_path%"

cmake --build %opencvBuild% --target ALL_BUILD --config Release
cmake --build %opencvBuild% --target INSTALL --config Release

Список источников

  1. docs.opencv.org/4.1.1/d3/d52/tutorial_windows_install.html
  2. www.learnopencv.com/install-opencv-4-on-windows
  3. jamesbowley.co.uk/build-opencv-4-0-0-with-cuda-10-0-and-intel-mkl-tbb-in-windows
  4. lightbuzz.com/opencv-cuda
  5. Глава «Building libraries from Source» книги Hands-on GPU-Accelerated Computer Vision with OpenCV and CUDA

There is a --user option for pip which can install a Python package per user:

pip install --user [python-package-name]

I used this option to install a package on a server for which I do not have root access. What I need now is to uninstall the installed package on the current user. I tried to execute this command:

pip uninstall --user [python-package-name]

But I got:

no such option: --user

How can I uninstall a package that I installed with pip install --user, other than manually finding and deleting the package?

I’ve found this article

pip cannot uninstall from per-user site-packages directory

which describes that uninstalling packages from user directory does not supported. According to the article if it was implemented correctly then with

pip uninstall [package-name]

the package that was installed will be also searched in user directories. But a problem still remains for me. What if the same package was installed both system-wide and per-user?
What if someone needs to target a specific user directory?

YaOzI's user avatar

YaOzI

14.9k7 gold badges72 silver badges71 bronze badges

asked Oct 29, 2015 at 11:27

Serjik's user avatar

5

Having tested this using Python 3.5 and pip 7.1.2 on Linux, the situation appears to be this:

  • pip install --user somepackage installs to $HOME/.local, and uninstalling it does work using pip uninstall somepackage.

  • This is true whether or not somepackage is also installed system-wide at the same time.

  • If the package is installed at both places, only the local one will be uninstalled. To uninstall the package system-wide using pip, first uninstall it locally, then run the same uninstall command again, with root privileges.

  • In addition to the predefined user install directory, pip install --target somedir somepackage will install the package into somedir. There is no way to uninstall a package from such a place using pip. (But there is a somewhat old unmerged pull request on Github that implements pip uninstall --target.)

  • Since the only places pip will ever uninstall from are system-wide and predefined user-local, you need to run pip uninstall as the respective user to uninstall from a given user’s local install directory.

answered Feb 20, 2016 at 14:20

Thomas Lotze's user avatar

Thomas LotzeThomas Lotze

5,0531 gold badge15 silver badges16 bronze badges

5

example to uninstall package ‘oauth2client’ on MacOS:

pip uninstall oauth2client

answered Mar 6, 2017 at 13:16

Huy - Logarit's user avatar

2

Be careful though, for those who using pip install --user some_pkg inside a virtual environment.

$ path/to/python -m venv ~/my_py_venv
$ source ~/my_py_venv/bin/activate
(my_py_venv) $ pip install --user some_pkg
(my_py_venv) $ pip uninstall some_pkg
WARNING: Skipping some_pkg as it is not installed.
(my_py_venv) $ pip list
# Even `pip list` will not properly list the `some_pkg` in this case

In this case, you have to deactivate the current virtual environment, then use the corresponding python/pip executable to list or uninstall the user site packages:

(my_py_venv) $ deactivate
$ path/to/python -m pip list
$ path/to/python -m pip uninstall some_pkg

Note that this issue was reported few years ago. And it seems that the current conclusion is: --user is not valid inside a virtual env’s pip, since a user location doesn’t really make sense for a virtual environment.

answered Jul 9, 2019 at 8:26

YaOzI's user avatar

YaOzIYaOzI

14.9k7 gold badges72 silver badges71 bronze badges

2

I strongly recommend you to use virtual environments for python package installation. With virtualenv, you prevent any package conflict and total isolation from your python related userland commands.

To delete all your package installed globally follow this;

It’s possible to uninstall packages installed with --user flag. This one worked for me;

pip freeze --user | xargs pip uninstall -y

For python 3;

pip3 freeze --user | xargs pip3 uninstall -y

But somehow these commands don’t uninstall setuptools and pip. After those commands (if you really want clean python) you may delete them with;

pip uninstall setuptools && pip uninstall pip

Now you have clean python environment. You can create virtualenv and install the package inside them.

answered Oct 28, 2019 at 19:23

thiras's user avatar

thirasthiras

4811 gold badge5 silver badges21 bronze badges

4

The answer is Not possible yet. You have to remove it manually.

answered Feb 20, 2016 at 15:32

sorin's user avatar

sorinsorin

157k172 gold badges522 silver badges784 bronze badges

3

As @thomas-lotze has mentioned, currently pip tooling does not do that as there is no corresponding —user option. But what I find is that I can check in ~/.local/bin and look for the specific pip#.# which looks to me like it corresponds to the —user option.

In my case:

antho@noctil: ~/.l/bin$ pwd
/home/antho/.local/bin
antho@noctil: ~/.l/bin$ ls pip*
pip  pip2  pip2.7  pip3  pip3.5

And then just uninstall with the specific pip version.

a different ben's user avatar

answered Aug 17, 2017 at 20:15

AnthonyC's user avatar

AnthonyCAnthonyC

1,8602 gold badges19 silver badges27 bronze badges

1

I am running Anaconda version 4.3.22 and a python3.6.1 environment, and had this problem. Here’s the history and the fix:

pip uninstall opencv-python # -- the original step. failed.

ImportError: DLL load failed: The specified module could not be found.

I did this into my python3.6 environment and got this error.

python -m pip install opencv-python # same package as above.
conda install -c conda-forge opencv # separate install parallel to opencv
pip-install opencv-contrib-python # suggested by another user here. doesn't resolve it.

Next, I tried downloading python3.6 and putting the python3.dll in the folder and in various folders. nothing changed.

finally, this fixed it:

pip uninstall opencv-python

(the other conda-forge version is still installed) This left only the conda version, and that works in 3.6.

>>>import cv2
>>>

working!

answered Sep 14, 2018 at 1:24

Marc Maxmeister's user avatar

Marc MaxmeisterMarc Maxmeister

3,9674 gold badges38 silver badges50 bronze badges

There is a --user option for pip which can install a Python package per user:

pip install --user [python-package-name]

I used this option to install a package on a server for which I do not have root access. What I need now is to uninstall the installed package on the current user. I tried to execute this command:

pip uninstall --user [python-package-name]

But I got:

no such option: --user

How can I uninstall a package that I installed with pip install --user, other than manually finding and deleting the package?

I’ve found this article

pip cannot uninstall from per-user site-packages directory

which describes that uninstalling packages from user directory does not supported. According to the article if it was implemented correctly then with

pip uninstall [package-name]

the package that was installed will be also searched in user directories. But a problem still remains for me. What if the same package was installed both system-wide and per-user?
What if someone needs to target a specific user directory?

YaOzI's user avatar

YaOzI

14.9k7 gold badges72 silver badges71 bronze badges

asked Oct 29, 2015 at 11:27

Serjik's user avatar

5

Having tested this using Python 3.5 and pip 7.1.2 on Linux, the situation appears to be this:

  • pip install --user somepackage installs to $HOME/.local, and uninstalling it does work using pip uninstall somepackage.

  • This is true whether or not somepackage is also installed system-wide at the same time.

  • If the package is installed at both places, only the local one will be uninstalled. To uninstall the package system-wide using pip, first uninstall it locally, then run the same uninstall command again, with root privileges.

  • In addition to the predefined user install directory, pip install --target somedir somepackage will install the package into somedir. There is no way to uninstall a package from such a place using pip. (But there is a somewhat old unmerged pull request on Github that implements pip uninstall --target.)

  • Since the only places pip will ever uninstall from are system-wide and predefined user-local, you need to run pip uninstall as the respective user to uninstall from a given user’s local install directory.

answered Feb 20, 2016 at 14:20

Thomas Lotze's user avatar

Thomas LotzeThomas Lotze

5,0531 gold badge15 silver badges16 bronze badges

5

example to uninstall package ‘oauth2client’ on MacOS:

pip uninstall oauth2client

answered Mar 6, 2017 at 13:16

Huy - Logarit's user avatar

2

Be careful though, for those who using pip install --user some_pkg inside a virtual environment.

$ path/to/python -m venv ~/my_py_venv
$ source ~/my_py_venv/bin/activate
(my_py_venv) $ pip install --user some_pkg
(my_py_venv) $ pip uninstall some_pkg
WARNING: Skipping some_pkg as it is not installed.
(my_py_venv) $ pip list
# Even `pip list` will not properly list the `some_pkg` in this case

In this case, you have to deactivate the current virtual environment, then use the corresponding python/pip executable to list or uninstall the user site packages:

(my_py_venv) $ deactivate
$ path/to/python -m pip list
$ path/to/python -m pip uninstall some_pkg

Note that this issue was reported few years ago. And it seems that the current conclusion is: --user is not valid inside a virtual env’s pip, since a user location doesn’t really make sense for a virtual environment.

answered Jul 9, 2019 at 8:26

YaOzI's user avatar

YaOzIYaOzI

14.9k7 gold badges72 silver badges71 bronze badges

2

I strongly recommend you to use virtual environments for python package installation. With virtualenv, you prevent any package conflict and total isolation from your python related userland commands.

To delete all your package installed globally follow this;

It’s possible to uninstall packages installed with --user flag. This one worked for me;

pip freeze --user | xargs pip uninstall -y

For python 3;

pip3 freeze --user | xargs pip3 uninstall -y

But somehow these commands don’t uninstall setuptools and pip. After those commands (if you really want clean python) you may delete them with;

pip uninstall setuptools && pip uninstall pip

Now you have clean python environment. You can create virtualenv and install the package inside them.

answered Oct 28, 2019 at 19:23

thiras's user avatar

thirasthiras

4811 gold badge5 silver badges21 bronze badges

4

The answer is Not possible yet. You have to remove it manually.

answered Feb 20, 2016 at 15:32

sorin's user avatar

sorinsorin

157k172 gold badges522 silver badges784 bronze badges

3

As @thomas-lotze has mentioned, currently pip tooling does not do that as there is no corresponding —user option. But what I find is that I can check in ~/.local/bin and look for the specific pip#.# which looks to me like it corresponds to the —user option.

In my case:

antho@noctil: ~/.l/bin$ pwd
/home/antho/.local/bin
antho@noctil: ~/.l/bin$ ls pip*
pip  pip2  pip2.7  pip3  pip3.5

And then just uninstall with the specific pip version.

a different ben's user avatar

answered Aug 17, 2017 at 20:15

AnthonyC's user avatar

AnthonyCAnthonyC

1,8602 gold badges19 silver badges27 bronze badges

1

I am running Anaconda version 4.3.22 and a python3.6.1 environment, and had this problem. Here’s the history and the fix:

pip uninstall opencv-python # -- the original step. failed.

ImportError: DLL load failed: The specified module could not be found.

I did this into my python3.6 environment and got this error.

python -m pip install opencv-python # same package as above.
conda install -c conda-forge opencv # separate install parallel to opencv
pip-install opencv-contrib-python # suggested by another user here. doesn't resolve it.

Next, I tried downloading python3.6 and putting the python3.dll in the folder and in various folders. nothing changed.

finally, this fixed it:

pip uninstall opencv-python

(the other conda-forge version is still installed) This left only the conda version, and that works in 3.6.

>>>import cv2
>>>

working!

answered Sep 14, 2018 at 1:24

Marc Maxmeister's user avatar

Marc MaxmeisterMarc Maxmeister

3,9674 gold badges38 silver badges50 bronze badges

Итак, прежде всего, я на Windows10, я работаю в среде tf-gpu, а не в базе. Это может быть долго, но никакая статья/пост/вопрос не помогла мне. Я пытался протестировать модуль обнаружения объектов, а теперь переходим к живому видео. У меня была ошибка:

error: OpenCV(4.5.4-dev) D:aopencv-pythonopencv-pythonopencvmoduleshighguisrcwindow.cpp:1268: 
error: (-2:Unspecified error) The function is not implemented. 
Rebuild the library with Windows, GTK+ 2.x or Cocoa support. 
If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows'

То же самое касается cv2.imshow. После удаления с помощью pip, использования conda и т. д. Я пошел в навигатор anaconda, чтобы проверить пакеты, они все еще там 2 пакета, установленных через pip channel pypi в cmd, поэтому я удалил opencv и opencv contrib и вуаля, без пакета.

pip uninstall opencv-python, pip uninstall opencv-contrib-python

Итак, я иду к своей записной книжке, видимо, я все еще могу импортировать cv2, хотя я уверен, что удалил его.

import cv2
cv2.__version__

'4.5.4-dev'

И у меня все еще есть та же ошибка выше.

Edit: я также пробовал эту команду:

pip3 install opencv-python --upgrade --force-reinstall
``
still the same error as above

1 ответ

Я убедился, что удалил все пакеты и просмотрел свою среду tf-gpu, если что-то существует, и выключил свой компьютер. Сегодня я открыл его, и у меня не было модуля с именем cv2.


0

Abdelrahman Rabah
4 Ноя 2021 в 13:01

Я попытался установить OpenCV в анаконду. но когда я его использую, я понимаю, что вместо использования OpenCV программа использует OpenCV-python и почему моя программа разбилась. Я набираю «conda uninstall opencv», но он просто удаляет пакет OpenCV, а не OpenCV-python. Я также использую «conda uninstall opencv-python» и «pip uninstall opencv-python», но это не работает.

введите описание изображения здесь

person
Lê Huy Hùng
  
schedule
03.01.2018
  
source
источник


Ответы (5)

@ Lê Huy Hùng

Пожалуйста, проверьте официальную документацию, прежде чем размещать подобный вопрос.

Вот официальная документация pip uninstall

Вот как я его удалил

pip удалить opencv-python

Перейдите в каталог, в который pip устанавливает ваши пакеты.

person
Santhosh
  
schedule
26.03.2018

  1. Вы должны увидеть файл яйца, соответствующий пакету, который вы хотите удалить. Удалите файл с яйцом (или, на всякий случай, переместите его в другой каталог).
  2. Сделайте то же самое с файлами пакета для пакета, который вы хотите удалить (opencv-python)
  3. Для удаления я использовал эту строку кода, и она сработала,

person
Prem
  
schedule
03.01.2018

comment

проверьте /usr/local/lib/python3.6/site-packages/ или /usr/lib/python3.6/site-packages/
person Lê Huy Hùng; 03.01.2018

comment

вам не нужно _1_ для установки или удаления пакетов с _2_.
person Prem; 03.01.2018

Результат как указано:

    sudo pip uninstall opencv-python

Согласно официальной документации, эту проблему нужно решить довольно легко:

Uninstalling opencv-python-4.0.0.21:   Would remove:

    c:program filesanaconda3libsite-packagescv2*
    c:program filesanaconda3libsite-packagesopencv_python-4.0.0.21.dist-info* Proceed (y/n)? y   Successfully uninstalled opencv-python-4.0.0.21

person
Developer Here
  
schedule
05.02.2019

comment

Пожалуйста, включите код в ответ, не используйте внешнее изображение (внешние ссылки могут сломаться в будущем)
person m_____z; 27.08.2019

Я запускаю на терминале следующий код:

pip uninstall opencv-python

. Это действительно хорошо работает. Вы можете увидеть: захваченный экран

pip uninstall opencv-python

person
Scott
  
schedule
27.08.2019

Я не могу найти, где pip устанавливает ваши пакеты, вы можете показать мне, где он находится на вашем компьютере

person
Al hamdulillah
  
schedule
23.07.2020

comment

Хотя эта ссылка может дать ответ на вопрос, лучше включить сюда основные части ответа и предоставить ссылку для справки. Ответы, содержащие только ссылки, могут стать недействительными, если ссылка на страницу изменится. — Из отзыва
person Riccardo Bucco; 23.07.2020

comment

Удаление opencv-python-3.4.0.12:
/Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/QtCore /Users/name/.virtualenvs/LT/lib /python3.5/site-packages/cv2/.dylibs/QtGui /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/QtTest /Users/name/.virtualenvs/LT /lib/python3.5/site-packages/cv2/.dylibs/libavcodec.57.107.100.dylib /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libavformat. 57.83.100.dylib /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libavresample.3.7.0.dylib /Users/name/.virtualenvs/LT/lib/python3 .5 / site-packages / cv2 / .dylibs / libavutil.55.78.100.dylib /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/.dylibs/libmp3lame.0.dylib / Пользователи / имя / .virtualenvs / LT / lib / python3.5 / site-packages / cv2 / .dylibs / libswresample.2.9.100.dylib /Users/name/.virtualenvs/LT/lib/python3.5/site-packages /cv2/.dylibs/libswscale.4.8.100.dylib /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/LICENSE-3RD-PARTY .txt /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/LICENSE.txt /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/ < strong> init .py /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/

/ init .cpython-35.pyc /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_eye.xml /Users/name/.virtualenvs /LT/lib/python3.5/site-packages/cv2/data/haarcascade_eye_tree_eyeglasses.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalcat.xml / Users имя / .virtualenvs / LT / lib / python3.5 / site-packages / cv2 / data / haarcascade_frontalcatface_extended.xml /Users/name/.virtualenvs/L T / lib / python3.5 / site-packages / cv2 / data / haarcascade_frontalface_alt.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalface_alt2.xml / Users / name /.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_frontalface_alt_tree.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/fronthaarcade_face_face. /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_fullbody.xml /Users/name/.virtualenvs/LT/lib/python3. 5 / site-packages / cv2 / data / haarcascade_lefteye_2splits.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_licence_plate_rus_16stages.xml /Users/names/Lirtu lib / python3.5 / site-packages / cv2 / data / haarcascade_lowerbody.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_profileface.xml / Users / name /. virtualenvs / LT / lib / python3.5 / site-packages / cv2 / data / haarcascade_righteye_2splits.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_russian_plate_number.xml /name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_smile.xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/cv2/data/haarcascade_upperbody .xml /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/DESCRIPTION.rst /Users/name/.virtualenvs/LT/lib/python3.5 /site-packages/opencv_python-3.4.0.12.dist-info/INSTALLER /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python -3.4.0.12.dist-info / METADATA /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/RECORD /Users/name/.virtualenvs/LT /lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/WHEEL /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist- info / metadata.json /Users/name/.virtualenvs/LT/lib/python3.5/site-packages/opencv_python-3.4.0.12.dist-info/top_level.txt Продолжить (да / нет)? y
Успешно удален opencv-python-3.4.0.12
person 10 Rep; 23.07.2020

У меня ошибка в OpenCV, когда я пытаюсь запустить код Python. Я пробовал бегать

import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread("watch.jpg", cv2.IMREAD_GRAYSCALE)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Но я получаю эту ошибку.

Ошибка OpenCV: неопределенная ошибка (Функция не реализована. Перестройте библиотеку с поддержкой Windows, GTK + 2.x или Carbon. Если вы работаете в Ubuntu или Debian, установите libgtk2.0-dev и pkg-config, а затем снова запустите cmake или настройте скрипт) в cvShowImage, файл /home/pankaja/Desktop/OpenCV-tmp/opencv/modules/highgui/src/window.cpp, строка 611
Traceback (последний вызов был последним):
Файл «/home/pankaja/PycharmProjects/ImageProcessing/imageprocess.py», строка 8, в
cv2.imshow (‘изображение’, img)
cv2.error: /home/pankaja/Desktop/OpenCV-tmp/opencv/modules/highgui/src/window.cpp:611: ошибка: (-2) Функция не реализована. Перестройте библиотеку с поддержкой Windows, GTK + 2.x или Carbon. Если вы используете Ubuntu или Debian, установите libgtk2.0-dev и pkg-config, затем повторно запустите cmake или настройте скрипт в функции cvShowImage

наконец, с некоторыми ошибками мне удалось установить libgtk2.0-dev и pkg-config (Следующие пакеты имеют неудовлетворенные зависимости OpenCV 3.2 Python 3.5), но все же это дает ошибку

Итак, теперь я думаю о новой установке на python 3.5 и OpenCV, чтобы решить эту проблему. Как я могу полностью удалить OpenCV?

2

Решение

У меня была одна и та же проблема. Я исправил проблему, полностью удалив opencv и переустановив его из исходного кода. Есть некоторые зависимости, такие как ffmpeg, которые вы должны установить.

РЕДАКТИРОВАТЬ:
Чтобы полностью удалить OpenCV

  1. Если вы установили из исходного кода, вы можете использовать следующую команду

    make uninstall

Запустите эту команду из директории сборки исходного кода opencv.

  1. Если вы установили с помощью pip

    sudo pip uninstall opencv

  2. Если вы установили с помощью apt-get

    sudo apt-get remove python-opencv

    sudo apt-get purge python-opencv

Я надеюсь, что это может помочь

3

Другие решения

У меня была та же самая ошибка в течение нескольких недель. Поэтому я решил переустановить opencv, как и вы.

Первый,sudo pip uninstall opencv
или если вы установили через apt-get,sudo apt-get remove python-opencv
После этого,pip install opencv-contrib-python
Это сработало как прелесть. Только получение ошибки при обработке видео. Угадайте, что это займет неделю, чтобы исправить это.

Источник:Посмотрите это, если вам нужны какие-либо разъяснения

2

Понравилась статья? Поделить с друзьями:
  • Как удалить office в windows 10 полностью через powershell
  • Как удалить onenote windows 10 полностью
  • Как удалить office 365 с компьютера windows 10
  • Как удалить onedrive с компьютера windows 10
  • Как удалить office 365 полностью windows 11 на новом ноутбуке