2017-04-30 155 views
1

如何在GCP中導入OpenCV?我在這裏使用Google Datalab。在Google Cloud Datalab中導入OpenCV

它看起來像我可以安裝該軟件包:

!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 

回答

3

我成功的下一步。

讓我們試試這個♥

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

並沒有爲我工作:「E:有未經認證的軟件包,並且-y的使用沒有--allow-unauthenticated「 – Bastiaan

0

它爲我用! apt-get的安裝python-OpenCV的-y --allow-未經驗證的

+0

你可以通過解釋你的代碼如何解決問題來改善你的答案嗎? –

相關問題