簡體   English   中英

ModuleNotFoundError:使用 google-cloud-vision api 時沒有名為“google”的模塊

[英]ModuleNotFoundError: No module named 'google' while using google-cloud-vision api

我運行了以下代碼

import io import os # Imports the Google Cloud client library from google.cloud import vision # Instantiates a client client = vision.ImageAnnotatorClient() # The name of the image file to annotate file_name = os.path.abspath('resources/wakeupcat.jpg') # Loads the image into memory with io.open(file_name, 'rb') as image_file: content = image_file.read() image = vision.Image(content=content) # Performs label detection on the image file response = client.label_detection(image=image) labels = response.label_annotations print('Labels:') for label in labels: print(label.description)

我得到的錯誤如下

Traceback (most recent call last): File "F:\coding\pythonfolder\main.py", line 4, in <module> from google.cloud import vision ModuleNotFoundError: No module named 'google'

安裝的庫如下

pip install google-cloud-vision

我對谷歌視覺 api 相當陌生,所以也許我遺漏了一些問題,請告訴我問題是什么,我嘗試了 pip install --upgrade --upgrade google-cloud-vision但似乎不適用於我的 Z23EEEB47BDD755BDDZ 版本是7347BDD755BDDZ Python 3.10.0如果我的問題中有任何問題或缺少信息,請告訴我謝謝

我很確定你搞砸了venv ,因為它對我來說很好用。 嘗試使用 PyCharm (如果你還沒有這樣做)並設置一個venv ,或者安裝virtualenv並在你的項目文件夾中啟動這些命令:

 virtualenv venv source venv/bin/activate pip install google-cloud-vision python your_file.py deactivate

最后一個是正確退出venv

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM