Python3.9.5を使用しています。
プロゲートの説明(https://prog-8.com/docs/python-env)に沿って環境構築を進め、
・Homebrewのインストール
・pyenvのインストール
・Pythonのインストール
は終えています。
また、確認のために
print('Hello, world!')
print(1 + 2) を実行したところ無事動作しました。
以前openCVをインストールした後
https://note.nkmk.me/python-opencv-numpy-color-to-gray/
でカラー画像のグレーケース化
import cv2
import numpy as np
im = cv2.imread('data/src/lena.jpg')
print(im.shape)
(225, 400, 3)
print(im.dtype)
uint8
を行なった際には正常に完了しました。
ただ、その後でパソコン内のデータを整理してしまったためかわかりませんが、pythonは使えてもopenCVが使えなくなってしまいました。
色々と試してみましたが、改善しませんでした。
下記を実行すると
import cv2
print(cv2.version)
pyenv shell 3.9.5
/Users/matsumototakahiro/.pyenv/versions/3.9.5/bin/python "/Users/matsumototakahiro/import cv2.py"
(base) matsumototakahiro@matsumotokouounoMacBook-Pro ~ % pyenv shell 3.9.5
(base) matsumototakahiro@matsumotokouounoMacBook-Pro ~ % /Users/matsumototakahiro/.pyenv/versions/3.9.5/bin/python "/Users/matsumotot
akahiro/import cv2.py"
Traceback (most recent call last):
File "/Users/matsumototakahiro/import cv2.py", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
(base) matsumototakahiro@matsumotokouounoMacBook-Pro ~ %
となってしまいました。
解決方法をご存知の方いらっしゃいましたら教えていただけませんでしょうか。
初心者で、解決するために必要な情報が分かりませんので、足りなければ後から付け足させていただきますので何卒よろしくお願いします。
以下、ネットなどを見て試した時にターミナルのコピーです。
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- opencv3=3.1.0 -> python[version='2.7.|3.4.|3.5.*']
Your python: python=3.9
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
(base) matsumototakahiro@matsumotokouounoMacBook-Pro ~ % pyenv install 3.5.0
Downloading openssl-1.0.2k.tar.gz...
-> https://pyenv.github.io/pythons/6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
Installing openssl-1.0.2k...
Installed openssl-1.0.2k to /Users/matsumototakahiro/.pyenv/versions/3.5.0
python-build: use readline from homebrew
Downloading Python-3.5.0.tar.xz...
-> https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
Installing Python-3.5.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 12.2.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/mb/66kfnj8x4_58063h521jwlw80000gn/T/python-build.20220404131025.51560
Results logged to /var/folders/mb/66kfnj8x4_58063h521jwlw80000gn/T/python-build.20220404131025.51560.log
Last 10 log lines:
checking for --with-cxx-main=<compiler>... no
checking for clang++... no
configure:
By default, distutils will build C++ extension modules with "clang++".
If this is not intended, then set CXX on the configure command line.
checking for the platform triplet based on compiler characteristics... darwin
configure: error: internal configure error for the platform triplet, please file a bug report
make: *** No targets specified and no makefile found. Stop.
(base) matsumototakahiro@matsumotokouounoMacBook-Pro ~ % pyenv versions
system
- 3.9.5 (set by /Users/matsumototakahiro/.python-version)
(base) matsumototakahiro@matsumotokouounoMacBook-Pro ~ %
回答1件
あなたの回答
tips
プレビュー