2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Mac】cv2のImportError(Reason: image not found)

Posted at

エラー内容

ImportError: dlopen(/Users/user/venv/lib/python3.8/site-packages/cv2/cv2.cpython-38-darwin.so, 2): Library not loaded: /opt/homebrew/opt/ffmpeg/lib/libavcodec.58.dylib
  Referenced from: /Users/user/venv/lib/python3.8/site-packages/cv2/cv2.cpython-38-darwin.so
  Reason: image not found

環境

  • homebrew 3.2.5
  • python 3.8
  • venv

状況

仮想環境上にてpipを使用しopencvをインストール後、importした時にエラーに遭遇

$ pip install opencv-python
$ python3
$ import cv2

解決策(備忘録)

ターミナルを開き、homebrewを使ってopenCVをインストール

$ brew install opencv

参考

「ググれよ自分」と言いたくなるが、homebrewを使い慣れていない状況で
この手のエラーに遭遇すると原因がわからず混乱する。

windows、mac、linuxなど複数のOSを使用していて、同じようにimport出来ると思い込んでいると沼にハマる。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?