OpenCV导入错误mac

时间:2018-04-24 10:37:03

标签: python opencv computer-vision

我正在尝试在我的Mac(OS High Sierra)上安装OpenCV,按照教程here进行一些小修改。为了完整起见,到目前为止,我已经完成了以下工作:

sudo xcode-select --install
export PATH=/usr/local/bin:$PATH >> /.bashrc
source ~/.bashrc

brew install python python3
brew link python
brew link python3
brew postinstall python3

pip3 install virtualenv virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 >> /.bashrc
export WORKON_HOME=$HOME/.virtualenvs PROJECT_HOME=$HOME/Develsource/usr/local/bin/virtualenvwrapper.sh >> /.bashrc
brew install opencv
echo /usr/local/opt/opencv/lib/python3.6/site-packages >> /usr/local/lib/python3.6/site-packages/opencv3.pth

这一切似乎都很好。在上文中,我将教程的WORKON_HOME更改为virtualenvs而不是virtualenvsexport

然后我进入我的虚拟环境:

mkvirtualenv cv-py3 -p python3
workon cv-py3
pip install numpy scipy scikit-image matplotlib scikit-learn
deactivate

现在我回去连接OpenCV:

cd ~/.virtualenvs/cv-py3/lib/python3.6/site-packages/
ln -s /usr/local/opt/opencv@3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so cv2.so

现在出现了问题:

workon cv-py3
python3
import cv2

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/JosephBullock/.virtualenvs/cv-py3test/lib/python3.6/site-packages/cv2.so, 2): Library not loaded: /usr/local/opt/tesseract/lib/libtesseract.3.dylib
  Referenced from: /usr/local/Cellar/opencv/3.4.1_3/lib/libopencv_text.3.4.dylib
  Reason: image not found

在这里,我不确定出了什么问题以及该怎么做。

1 个答案:

答案 0 :(得分:0)

您必须安装库&#34; tesseract&#34;。执行以下命令:

brew install tesseract