[英]OpenCV import error mac
I'm trying to install OpenCV on my Mac (OS High Sierra), following the tutorial here with some minor modifications. 我正在尝试在Mac(OS High Sierra)上安装OpenCV,并按照此处的说明进行了一些小的修改。 For completeness, so far I have done the following:
为了完整起见,到目前为止,我已执行以下操作:
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
This all seems to work fine. 这一切似乎都很好。 In the above I changed the tutorial's
WORKON_HOME
to virtualenvs
rather than virtualenvsexport
. 在上面,我将教程的
WORKON_HOME
更改为virtualenvs
而不是virtualenvsexport
。
Then I go in to my virtual env: 然后进入虚拟环境:
mkvirtualenv cv-py3 -p python3
workon cv-py3
pip install numpy scipy scikit-image matplotlib scikit-learn
deactivate
Now I go back and link OpenCV: 现在,我返回并链接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
Now comes the problem: 现在出现了问题:
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
It is here that I'm not sure what's gone wrong and what to do. 在这里,我不确定哪里出了问题以及该怎么做。
You have to install the library "tesseract". 您必须安装库“ tesseract”。 Execute the following command:
执行以下命令:
brew install tesseract
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.