I built the OpenCV4 by Cmake and installed the opecv4.0 using anaconda3 with its python 3.7 verison. My platform is Ubuntu 18.04 LTS. However, when testing the installation, I encounter the following problem:
ype "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda3/lib/python3.7/site-packages/cv2/__init__.py", line 89, in <module>
bootstrap()
File "/home/user/anaconda3/lib/python3.7/site-packages/cv2/__init__.py", line 62, in bootstrap
], True)
File "/home/user/anaconda3/lib/python3.7/site-packages/cv2/__init__.py", line 56, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.7.py', 'config-3.py']. Check OpenCV installation.
>>>
I typed the command:
echo $PYTHONPATH
I get:
/home/user/anaconda3/lib/python3.7/site-packages
Updated:
I found that the /home/user/anaconda3/lib/python3.7/site-packages/cv2/ does not contain the config-3.7.py, but it contains config-3.6.py. At the beginning, I ensured that all python3 are correlated to the anaconda's python 3.7 library. I don't know why the cv2 folder still uses the Ubuntu's default python.
I have tried deleting the cv2 folder and rebuild it again, but it still generates the config-3.6.py file. I don't know why it will like this.
By the way, I didn't turn on the opencv python3 verison in Cmake config of building OpenCV, will it be affected?
Please help. Thanks
A part of Cmake is here:
After modifying the Cmake config following the instruction from and removing python2 related setting , I clear the build folder and rebuilt again.
But I did pip3 install --upgrade, but the cv2 folder still contain the config-3.6.py. When I typed pip3 install --upgrade opencv-python, other errors form:
Error initializing plugin EntryPoint('Windows (alt)', 'keyrings.alt.Windows', None, Distribution('keyrings.alt', '3.0')).
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/keyring/backend.py", line 194, in _load_plugins
init_func = ep.load()
File "/home/user/anaconda3/lib/python3.7/site-packages/entrypoints.py", line 82, in load
mod = import_module(self.module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/Windows.py", line 9, in <module>
from . import file_base
File "/usr/lib/python3/dist-packages/keyrings/alt/file_base.py", line 13, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint('file', 'keyrings.alt.file', None, Distribution('keyrings.alt', '3.0')).
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/keyring/backend.py", line 194, in _load_plugins
init_func = ep.load()
File "/home/user/anaconda3/lib/python3.7/site-packages/entrypoints.py", line 82, in load
mod = import_module(self.module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/file.py", line 11, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint('pyfs', 'keyrings.alt.pyfs', None, Distribution('keyrings.alt', '3.0')).
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/keyring/backend.py", line 194, in _load_plugins
init_func = ep.load()
File "/home/user/anaconda3/lib/python3.7/site-packages/entrypoints.py", line 82, in load
mod = import_module(self.module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/pyfs.py", line 8, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal.main import main
ModuleNotFoundError: No module named 'pip._internal.main'
config-3.6.py.