【问题标题】:import cv2 in Sagemaker Studio jupyter notebook throws ImportError: libGL.so.1: cannot open shared object file: No such file or directory在 Sagemaker Studio jupyter notebook 中导入 cv2 抛出 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
【发布时间】:2020-08-23 07:00:31
【问题描述】:

我已经运行了pip install opencv-python,但是当我运行import cv2 时,我收到了这个错误ImportError: libGL.so.1: cannot open shared object file: No such file or directory。我也尝试了这里描述的步骤https://docs.opencv.org/4.4.0/d2/de6/tutorial_py_setup_in_ubuntu.html

【问题讨论】:

    标签: python opencv jupyter-notebook amazon-sagemaker


    【解决方案1】:

    使用来自here的sagars回答

    sudo apt update
    sudo apt install libgl1-mesa-glx
    

    【讨论】:

    • 如果您没有对运行 Jupyter 的主机的 root 访问权限,这将如何工作?
    • !pip install opencv-python-headless 而不是 !pip install opencv-python 应该可以解决问题
    【解决方案2】:

    如果你的环境不允许你sudo,你可以代替标准的opencv-python包,获取它的headless版本

    !pip install opencv-python-headless
    

    它带来了它的二进制文件

    【讨论】:

      猜你喜欢
      • 2020-11-05
      • 2018-05-22
      • 2021-02-16
      • 2020-04-10
      • 1970-01-01
      • 2023-02-25
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多