简体   繁体   中英

ModuleNotFoundError: No module named 'google.colab' - Python

I'm following a tutorial to make a face recognition program in python i don't have quite the experience working in python and I am getting this error

line 35, in from google.colab.patches import cv2_imshow ModuleNotFoundError: No module named 'google.colab'

this is my code

from google.colab.patches import cv2_imshow
import cv2
imroot = str(input("Enter Image Path:\n"))
imroot = str("demo_img.jpg")
img = cv2.imread(imroot)
imshow(img)
cv2.waitKey()

i tried searching on google i find this stack overflow question How to resolve ModuleNotFoundError: No module named 'google.colab' so i tried installing google.colab.patches locally but it tells me to install MS Visual C++ i searched on google and found out that i would have to install MS Visual Studio (not VS code), so is there and alternative for displaying images other than importing cv2_imshow from google.colab.patches

so is there and alternative for displaying images other than importing cv2_imshow from google.colab.patches

Yes, you can either use Image.show from to trigger the Image Viewer of your system:

#pip install pillow
from PIL import Image

img = Image.open("Pictures/Stack_Overflow_logo.png")

img.show()

Or, if you're using Jupyter Notebook, use IPython.display.Image :

from IPython.display import Image

Image("Pictures/Stack_Overflow_logo.png")

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM