在Google Cloud Datalab中导入OpenCV

时间:2017-04-30 13:50:20

标签: python opencv 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

2 个答案:

答案 0 :(得分:4)

我成功完成了下一步。

让我们试试这个♥

!apt-get update
!apt-get -y upgrade
!pip install opencv-python
!apt-get install libgtk2.0-dev -y

答案 1 :(得分:-1)

它对我有用: !apt-get install python-opencv -y --allow-unauthenticated