How to uninstall pip opencv-python from Anaconda on Windows 10?
Cause the package was installed by pip
, you have to uninstall the package by pip uninstall
.
The problem is that the uninstallation was interrupted cause some files are being taken by another process.
To solve this, reinstall the package. Then uninstall it.
pip install opencv-python -f
pip uninstall opencv-python
Related videos on Youtube
T Walker
Updated on June 04, 2022Comments
-
T Walker almost 2 years
I wanted to ask a specific question before I try anything else and possibly ruin my Anaconda distribution.
conda version: 4.7.11 anaconda version: 2019.07 python version: 3.7.3
I installed
opencv-python
per the instructions here:(base) C:\Users\...>pip install opencv-python
I thought this had worked because I was able to run defs from
import cv2
in my Spyder IDE, andconda list
returned:... numpydoc 0.9.1 py_0 olefile 0.46 py37_0 opencv-python 4.1.1.26 pypi_0 pypi openpyxl 2.6.2 py_0 ...
However, I quickly ran into problems when attempting the tutorial. Specifically,
img = cv2.imread('messi5.jpg',0)
would return aNone
object. I triedimg = cv2.imread(r'C:\path_to_my_image.jpg',0)
with a local photo, and it correctly returned a 2D, grayscale object array. I'm confident I simply failed to install the photo library that comes with opencv.I anticipated more problems and did some digging, where I found this answer shows that I probably did not install the correct version of cv. I attempted to uninstall using
pip
, but had a text file from the active directory open, and got a permission error!(base) C:\Users\triton>pip uninstall opencv-python Uninstalling opencv-python-4.1.1.26: Would remove: c:\users\triton\anaconda3\lib\site-packages\cv2\* c:\users\triton\anaconda3\lib\site-packages\opencv_python-4.1.1.26.dist-info\* Proceed (y/n)? y ERROR: Exception: Traceback (most recent call last): File "C:\Users\triton\Anaconda3\lib\shutil.py", line 563, in move os.rename(src, real_dst) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\triton\\anaconda3\\lib\\site-packages\\opencv_python-4.1.1.26.dist-info\\' -> 'c:\\users\\triton\\anaconda3\\lib\\site-packages\\~pencv_python-4.1.1.26.dist-info' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\triton\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 178, in main status = self.run(options, args) File "C:\Users\triton\Anaconda3\lib\site-packages\pip\_internal\commands\uninstall.py", line 75, in run auto_confirm=options.yes, verbose=self.verbosity > 0, File "C:\Users\triton\Anaconda3\lib\site-packages\pip\_internal\req\req_install.py", line 823, in uninstall uninstalled_pathset.remove(auto_confirm, verbose) File "C:\Users\triton\Anaconda3\lib\site-packages\pip\_internal\req\req_uninstall.py", line 388, in remove moved.stash(path) File "C:\Users\triton\Anaconda3\lib\site-packages\pip\_internal\req\req_uninstall.py", line 277, in stash renames(path, new_path) File "C:\Users\triton\Anaconda3\lib\site-packages\pip\_internal\utils\misc.py", line 305, in renames shutil.move(old, new) File "C:\Users\triton\Anaconda3\lib\shutil.py", line 575, in move rmtree(src) File "C:\Users\triton\Anaconda3\lib\shutil.py", line 513, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\triton\Anaconda3\lib\shutil.py", line 401, in _rmtree_unsafe onerror(os.rmdir, path, sys.exc_info()) File "C:\Users\triton\Anaconda3\lib\shutil.py", line 399, in _rmtree_unsafe os.rmdir(path) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\triton\\anaconda3\\lib\\site-packages\\opencv_python-4.1.1.26.dist-info\\'
I closed the text file and tried to run
pip uninstall opencv-python
again, but now receive:(base) C:\Users\triton>pip uninstall opencv-python WARNING: Skipping opencv-python as it is not installed.
I do not know if this warning is accurate, because
conda list
still showsopencv-python
as an available package:... olefile 0.46 py37_0 opencv-python 4.1.1.26 pypi_0 pypi openpyxl 2.6.2 py_0 openssl 1.1.1c he774522_1 ...
i finally tried
conda remove opencv-python
but it says the packages aren't found?!(base) C:\Users\triton>conda remove opencv-python Collecting package metadata (repodata.json): done Solving environment: failed PackagesNotFoundError: The following packages are missing from the target environment: - opencv-python
I want to perform a clean
opencv3
install via this method, but don't know if there will be some library conflicts or something. I am severely confused about what's happening here, and wanted to get advice before trying to alter my distribution any further. It's not the end of the world if I need to reinstall Anaconda entirely, but I thought i would share these problems in case someone else runs into them!How can I be sure all opencv pip files are completely removed, without doing a clean reinstall of Anaconda?
Thanks in advance for your help!
-
CypherX over 4 yearsCreate a virtual environment and install either with conda or pip as you like. If it doesn’t work out, you could just delete that environment.
-
Dylan Freeman over 4 yearsGo to environments, and simply search for the module you wish to disable, when it appears, untick the desired module and click 'apply' to disable.
-
T Walker over 4 years"CypherX" comment does not solve the question, in which i do not want left over files in my base environment. i did not try "Dylan Freeman" 's suggestion, but have already done a clean install of anaconda. However, working with environments are good suggestions, and i'll probably use an older version of python with opencv in an env separate from my base env.
-
-
T Walker over 4 yearsi ended up doing a clean install of anaconda to simplify things. although, i did not try you're suggestion, i'm pretty sure this would've worked. someone else will have to test this if they ever come across the same problem. thanks to everybody for the comments!