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, and conda 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 a None
object. I tried img = 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 shows opencv-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!