前提
pyinstallerでexeを作成しました
cv2をインストールをしていたのですが、pyinstallerで作成したexeを起動させると、cv2に関してのエラーが発生します
実現したいこと
ここに実現したいことを箇条書きで書いてください。
- ▲▲機能を動作するようにする
発生している問題・エラーメッセージ
File "retina_cv2mosaic_input.py", line 5, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "cv2\__init__.py", line 181, in <module> bootstrap() File "cv2\__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "importlib\__init__.py", line 127, in import_module applySysPathWorkaround = True File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "cv2\__init__.py", line 181, in <module> bootstrap() File "cv2\__init__.py", line 76, in bootstrap raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.') ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation. [17600] Failed to execute script 'retina_cv2mosaic_input' due to unhandled exception!
該当のソースコード
# -*- coding: utf-8 -*- import argparse import cv2 from retinaface import RetinaFace def main(): parser = argparse.ArgumentParser(description='顔画像をモザイクにする') parser.add_argument("arg1") args = parser.parse_args() img = cv2.imread(args.arg1) dst_area = img.copy() resp = RetinaFace.detect_faces(dst_area, threshold = 0.5) print("faces:" + str(len(resp))) for key in resp: identity = resp[key] #--------------------- facial_area = identity["facial_area"] dst_area = mosaic_area(dst_area, facial_area[0], facial_area[1], (facial_area[2]-facial_area[0]), (facial_area[3]-facial_area[1]) , 0.1) cv2.imwrite(r'C:\Users\008D42\Pictures\output.'+ args.arg1.split(".")[1], dst_area) def int_tuple(t): return tuple(int(x) for x in t) def mosaic(src, ratio=0.1): small = cv2.resize(src, None, fx=ratio, fy=ratio, interpolation=cv2.INTER_NEAREST) return cv2.resize(small, src.shape[:2][::-1], interpolation=cv2.INTER_NEAREST) def mosaic_area(src, x, y, width, height, ratio): dst = src.copy() dst[y:y + height, x:x + width] = mosaic(dst[y:y + height, x:x + width], ratio) return dst if __name__ == "__main__": main() #------------------------------ #alignment """ img_path = "dataset/img11.jpg" resp = RetinaFace.extract_faces(img_path = img_path, align = True) for img in resp: plt.imshow(img[:, :, ::-1]) plt.axis('off') plt.show() cv2.imwrite('outputs/'+img_path.split("/")[1], img) """
試したこと
python -m pip listで確認した結果
Package Version ---------------------------- ----------- absl-py 1.1.0 albumentations 1.2.0 altgraph 0.17.2 astunparse 1.6.3 beautifulsoup4 4.11.1 cachetools 5.2.0 certifi 2022.6.15 charset-normalizer 2.1.0 colorama 0.4.5 cycler 0.11.0 Cython 0.29.30 easydict 1.9 filelock 3.7.1 flatbuffers 1.12 fonttools 4.34.4 future 0.18.2 gast 0.4.0 gdown 4.5.1 google-auth 2.9.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 grpcio 1.47.0 h5py 3.7.0 idna 3.3 imageio 2.19.3 importlib-metadata 4.12.0 joblib 1.1.0 keras 2.9.0 Keras-Preprocessing 1.1.2 kiwisolver 1.4.3 libclang 14.0.1 Markdown 3.3.7 matplotlib 3.5.2 networkx 2.8.4 numpy 1.23.1 oauthlib 3.2.0 onnx 1.12.0 onnxruntime 1.11.1 onnxruntime-gpu 1.11.1 opencv-python 4.6.0.66 opencv-python-headless 4.6.0.66 opt-einsum 3.3.0 packaging 21.3 pefile 2022.5.30 Pillow 9.2.0 pip 22.1.2 prettytable 3.3.0 protobuf 3.19.4 pyasn1 0.4.8 pyasn1-modules 0.2.8 pyinstaller 5.2 pyinstaller-hooks-contrib 2022.8 pyparsing 3.0.9 PySocks 1.7.1 python-dateutil 2.8.2 PyWavelets 1.3.0 pywin32-ctypes 0.2.0 PyYAML 6.0 qudida 0.0.4 requests 2.28.1 requests-oauthlib 1.3.1 retina-face 0.0.12 rsa 4.8 scikit-image 0.18.3 scikit-learn 1.1.1 scipy 1.8.1 setuptools 63.1.0 six 1.16.0 soupsieve 2.3.2.post1 tensorboard 2.9.1 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow 2.9.1 tensorflow-estimator 2.9.0 tensorflow-io-gcs-filesystem 0.26.0 termcolor 1.1.0 threadpoolctl 3.1.0 tifffile 2022.5.4 tqdm 4.64.0 typing_extensions 4.3.0 urllib3 1.26.10 wcwidth 0.2.5 Werkzeug 2.1.2 wheel 0.37.1 wrapt 1.14.1 zipp 3.8.0
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー