在 Google Cloud Datalab 中导入 OpenCV
Import OpenCV in Google Cloud Datalab
如何在GCP中导入OpenCV?我在这里使用 Google Datalab。
看来我可以安装包了:
!pip install opencv-python
Collecting opencv-python
Downloading opencv_python-3.2.0.7-cp27-cp27mu-manylinux1_x86_64.whl (6.7MB)
100% |################################| 6.7MB 98kB/s
Requirement already satisfied: numpy>=1.11.1 in
/usr/local/lib/python2.7/dist-packages (from opencv-python)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.2.0.7
但是我导入cv2后,出现错误
import cv2
ImportErrorTraceback (most recent call last)
<ipython-input-17-72fbbcfe2587> in <module>()
----> 1 import cv2
/usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>()
5 os.environ["PATH"] += os.pathsep + os.path.dirname(os.path.realpath(__file__))
6
----> 7 from . import cv2
8 sys.modules['cv2'] = cv2
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
我下一步成功了
让我们试试这个♥
!apt-get update
!apt-get -y upgrade
!pip install opencv-python
!apt-get install libgtk2.0-dev -y
它对我有用:
!apt-get install python-opencv -y --allow-unauthenticated
如何在GCP中导入OpenCV?我在这里使用 Google Datalab。
看来我可以安装包了:
!pip install opencv-python
Collecting opencv-python
Downloading opencv_python-3.2.0.7-cp27-cp27mu-manylinux1_x86_64.whl (6.7MB)
100% |################################| 6.7MB 98kB/s
Requirement already satisfied: numpy>=1.11.1 in
/usr/local/lib/python2.7/dist-packages (from opencv-python)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.2.0.7
但是我导入cv2后,出现错误
import cv2
ImportErrorTraceback (most recent call last)
<ipython-input-17-72fbbcfe2587> in <module>()
----> 1 import cv2
/usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>()
5 os.environ["PATH"] += os.pathsep + os.path.dirname(os.path.realpath(__file__))
6
----> 7 from . import cv2
8 sys.modules['cv2'] = cv2
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
我下一步成功了
让我们试试这个♥
!apt-get update
!apt-get -y upgrade
!pip install opencv-python
!apt-get install libgtk2.0-dev -y
它对我有用: !apt-get install python-opencv -y --allow-unauthenticated