0
2

More than 3 years have passed since last update.

Macでopencv-python

Posted at

ブログにあったちょっと前(2020/01/25)の記事を転載。


pythonで画像認識を思い、環境を構築しようとしたところ詰まったので構築メモ。
python環境はpipenvを使っています。

opencvインストール

$ pipenv install opencv-python

Installing opencv-python…
Adding opencv-python to Pipfile's [packages]…
✔ Installation Succeeded 
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed! 
...(中略)
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches opencv-python
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches opencv-python
No versions found
Was https://pypi.org/simple reachable?
...(中略)
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches opencv-python
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches opencv-python
No versions found
Was https://pypi.org/simple reachable?

大量のエラー。
メッセージに従って

$ pipenv lock --clear

も無意味。

別の案内に従って

$ pipenv install --skip-lock opencv-python
Installing opencv-python…
Adding opencv-python to Pipfile's [packages]…
✔ Installation Succeeded 
Installing dependencies from Pipfile…
An error occurred while installing opencv-python! Will try again.
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:08
Installing initially failed dependencies…
...(中略)
[pipenv.exceptions.InstallError]: ['Could not fetch URL https://pypi.org/simple/opencv-python/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=\'pypi.org\', port=443): Max retries exceeded with url: /simple/opencv-python/ (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.")) - skipping']
...(略)

"Can\'t connect to HTTPS URL because the SSL module is not available."
なるほどー。
ナニコレ。

(参考)pip install でSSL関連のエラーが出たらこれを読め!!!
pythonを最新にしたらいいらしい。
今インストールされているのは3.7.1。
現在(2020/01/25)の最新版は3.8.1なので、入れ直そう。

$ rm -rf Pipenv* .venv
$ pipenv --python 3.8.1
$ pipenv shell
$ pipenv install opencv-python
Installing opencv-python…
Adding opencv-python to Pipfile's [packages]…
✔ Installation Succeeded 
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success! 
Updated Pipfile.lock (ee14b3)!
Installing dependencies from Pipfile.lock (ee14b3)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:02

できたわー。

0
2
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
0
2