我正在使用 Google 云函式 Gen2 和 Python 3.10 以及最新版本的 gcloud cliopencv-python==4.6.0.66和functions-framework==3.2.0
我無法在谷歌云上部署,因為import cv2導致此錯誤
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
at .import_module ( /opt/python3.10/lib/python3.10/importlib/__init__.py:126 )
at .bootstrap ( /layers/google.python.pip/pip/lib/python3.10/site-packages/cv2/__init__.py:153 )
at .<module> ( /layers/google.python.pip/pip/lib/python3.10/site-packages/cv2/__init__.py:181 )
at .<module> ( /workspace/functions.py:20 )
at .<module> ( /workspace/endpoints.py:9 )
at .<module> ( /workspace/main.py:2 )
at ._call_with_frames_removed ( <frozen importlib._bootstrap>:241 )
at .exec_module ( <frozen importlib._bootstrap_external>:883 )
at .create_app ( /layers/google.python.pip/pip/lib/python3.10/site-packages/functions_framework/__init__.py:289 )
at ._cli ( /layers/google.python.pip/pip/lib/python3.10/site-packages/functions_framework/_cli.py:37 )
at .invoke ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:760 )
at .invoke ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:1404 )
at .main ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:1055 )
at .__call__ ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:1130 )
at .<module> ( /layers/google.python.pip/pip/bin/functions-framework:8 )
如果我opencv-python-headless改用,我會收到此錯誤
ImportError: Unable to find zbar shared library
at .load ( /layers/google.python.pip/pip/lib/python3.10/site-packages/pyzbar/zbar_library.py:65 )
at .load_libzbar ( /layers/google.python.pip/pip/lib/python3.10/site-packages/pyzbar/wrapper.py:127 )
at .zbar_function ( /layers/google.python.pip/pip/lib/python3.10/site-packages/pyzbar/wrapper.py:148 )
at .<module> ( /layers/google.python.pip/pip/lib/python3.10/site-packages/pyzbar/wrapper.py:151 )
at .<module> ( /layers/google.python.pip/pip/lib/python3.10/site-packages/pyzbar/pyzbar.py:7 )
at .<module> ( /workspace/functions.py:22 )
at .<module> ( /workspace/endpoints.py:9 )
at .<module> ( /workspace/main.py:2 )
at ._call_with_frames_removed ( <frozen importlib._bootstrap>:241 )
at .exec_module ( <frozen importlib._bootstrap_external>:883 )
at .create_app ( /layers/google.python.pip/pip/lib/python3.10/site-packages/functions_framework/__init__.py:289 )
at ._cli ( /layers/google.python.pip/pip/lib/python3.10/site-packages/functions_framework/_cli.py:37 )
at .invoke ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:760 )
at .invoke ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:1404 )
at .main ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:1055 )
at .__call__ ( /layers/google.python.pip/pip/lib/python3.10/site-packages/click/core.py:1130 )
at .<module> ( /layers/google.python.pip/pip/bin/functions-framework:8 )
OpenCV 是必備條件。可以修復此錯誤還是應該將專案部署到其他地方?
uj5u.com熱心網友回復:
問題總結
libgl 的第一個錯誤可以通過安裝 opencv-python-headless 來解決(它只是 CPU,不需要 libgl)
pyzbar 同樣需要安裝zbar。 (不能在云功能環境中完成)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/525291.html
標籤:Google Cloud Collective Pythonpython-3.xopencv谷歌云平台谷歌云功能
上一篇:將URL卷曲到vb.net
