【发布时间】:2021-06-06 02:42:50
【问题描述】:
我克隆了opencv 和opencv-contrib GitHub 并使用cuda 构建和安装。以下是使用的 python 标志。
在 opencv 构建中,我可以看到 cv2 模块和 python 示例。
s1n7ax@s1n7ax:~/workspace/opencv/build$ tree python_loader samples
python_loader
├── cv2
│ ├── config.py
│ ├── _extra_py_code
│ │ └── __init__.py
│ ├── __init__.py
│ ├── load_config_py2.py
│ └── load_config_py3.py
└── setup.py
samples
...
├── python
│ ├── CMakeFiles
│ │ ├── CMakeDirectoryInformation.cmake
│ │ └── progress.marks
│ ├── cmake_install.cmake
│ ├── CTestTestfile.cmake
│ └── Makefile
...
安装时,它会记录以下消息。
sudo make install
-- OpenCV Python: during development append to PYTHONPATH: /home/s1n7ax/workspace/opencv/build/python_loader
安装完成后,我添加了python的路径并运行。
export PYTHONPATH=/home/s1n7ax/workspace/opencv/build/python_loader && python3
但是,我无法正确导入 cv2 模块。
Python 3.8.5 (default, May 27 2021, 13:30:53)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/s1n7ax/workspace/opencv/build/python_loader/cv2/__init__.py", line 117, in <module>
bootstrap()
File "/home/s1n7ax/workspace/opencv/build/python_loader/cv2/__init__.py", line 73, in bootstrap
load_first_config([
File "/home/s1n7ax/workspace/opencv/build/python_loader/cv2/__init__.py", line 70, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.8.py', 'config-3.py']. Check OpenCV installation.
如何解决这个问题?
【问题讨论】:
-
你可以尝试``` pip3 install --upgrade opencv-python``` 和
pip3 install --upgrade pyinstaller在cmake中,检查你的python3路径
标签: python python-3.x opencv