Homebrew-core: opencv3: Missing dependencies

Created on 6 Mar 2018  路  7Comments  路  Source: Homebrew/homebrew-core

  • [X] are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
  • [X] have a problem with brew install (or upgrade, reinstall) a single, official formula (not cask)? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new. If it's a brew cask problem please file this issue at https://github.com/caskroom/homebrew-cask/issues/new. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • [X] ran brew update and can still reproduce the problem?
  • [X] ran brew doctor, fixed all issues and can still reproduce the problem?
  • [X] ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • [X] if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?
$ brew config
HOMEBREW_VERSION: 1.5.8
ORIGIN: https://github.com/Homebrew/brew
HEAD: 08f7e8c5887d1c654a1a5d5bc851a9c9d5a00371
Last commit: 4 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: bd37905e33a3b3ca8ba52e74c85c66377302f482
Core tap last commit: 28 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_RUBY_WARNINGS: -W0
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 9.0 build 900
Git: 2.13.5 => /Applications/Xcode_9.0.0_fb.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Ruby: /Users/mjpieters/.rbenv/shims/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: 1.8.0_144, 1.7.0_97
macOS: 10.13.3-x86_64
Xcode: 9.0 => /Applications/Xcode_9.0.0_fb.app/Contents/Developer
CLT: 9.2.0.0.1.1510905681
X11: N/A
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /opt/homebrew/bin/python3.5m-config
  /opt/homebrew/bin/python2-config
  /opt/homebrew/bin/python3.6m-config
  /opt/homebrew/bin/python2.7-config
  /opt/homebrew/bin/ksba-config
  /opt/homebrew/bin/python3.5-config
  /opt/homebrew/bin/python-config
  /opt/homebrew/bin/libassuan-config
  /opt/homebrew/bin/gpg-error-config
  /opt/homebrew/bin/python3.6-config
  /opt/homebrew/bin/libgcrypt-config
  /opt/homebrew/bin/pth-config

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libiperf.0.dylib
  /usr/local/lib/libykpers-1.1.dylib
  /usr/local/lib/libyubikey.0.dylib
  /usr/local/lib/libyubikey.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/iperf_api.h

Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
  /usr/local/lib/libiperf.la

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libiperf.a
  /usr/local/lib/libyubikey.a

Warning: Your Xcode (9.0) is outdated.
Please update to Xcode 9.2 (or delete it).
Xcode can be updated from the App Store.


Warning: Some keg-only formulae are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
the `./configure` step. This may cause problems when compiling those
other formulae.

Binaries provided by keg-only formulae may override system binaries
with other strange results.

You may wish to `brew unlink` these brews:
  python@2

To help us debug your issue please explain:

I'm trying to install and use opencv3 as a Python library. After brew install python and brew install opencv3 there appear to be dependencies missing:

$ /usr/local/bin/python3 -c 'import cv2; print(cv2)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.101.dylib
  Referenced from: /usr/local/Cellar/opencv/3.4.1_1/lib/libopencv_hdf.3.4.dylib
  Reason: image not found

So we run brew install hdf5 and try again:

$ /usr/local/bin/python3 -c 'import cv2; print(cv2)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/tesseract/lib/libtesseract.3.dylib
  Referenced from: /usr/local/Cellar/opencv/3.4.1_1/lib/libopencv_text.3.4.dylib
  Reason: image not found

Hrm, more dependencies. brew install tesseract and try again:

$ /usr/local/bin/python3 -c 'import cv2; print(cv2)'
<module 'cv2' from '/usr/local/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so'>

So hdf5 and tesseract are required dependencies. Please update the formula to include all required dependencies.

Most helpful comment

I hit the same ImportError when tying to import cv2 in either python 2 or 3. Doing both brew install hdf5 and brew install tesseract fixed it for me too.

All 7 comments

I hit the same ImportError when tying to import cv2 in either python 2 or 3. Doing both brew install hdf5 and brew install tesseract fixed it for me too.

Oh, and the two installs for hdf5 and tesseract also fixed brew test opencv which was broken beforehand. Sorry, I didn't get a screenshot of the error.

Closed via #24951.

brew update && brew upgrade and this should be fixed.

I came across the same problem that showing Library not loaded: /usr/local/opt/opencv/lib/libopencv_text.3.4.dylib I have run brew update && brew upgrade, brew install hdf5 and brew install tesseract. Still does not work.

@lightingghost whatever software you have that is using opencv also needs to be rebuilt from source.

@ilovezfs Thanks I recompiled and it works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sstadick picture sstadick  路  4Comments

xeoneux picture xeoneux  路  3Comments

dredmorbius picture dredmorbius  路  3Comments

yuna9 picture yuna9  路  4Comments

gregvirgin picture gregvirgin  路  3Comments