重要错误: 没有名为“谷歌”的模块

我安装了 Python 3.5。我运行了 pip install google命令并验证了模块。

我安装了 水蟒3.5并尝试运行 z 示例代码。但我收到了进口错误。请查看附件中的截图。 我错过了什么?是否需要以某种方式将 Spyder 链接到 Python 安装目录?为什么 Spyder 无法谷歌模块?

我的 Python 安装目录: C: UserXXXAppDataLocalProgramsPython35

Enter image description here

Enter image description here

我的场景有点不同,我无法从类似的帖子中找到解决方案。

310817 次浏览

I figured out the solution:

  • I had to delete my Anaconda and Python installations
  • Re-install Anaconda only
  • Open the Anaconda prompt and point it to Anaconda/Scripts
  • Run pip install google
  • Run the sample code now from Spyder.

No more errors.

I solved the problem in this way:

  1. sudo pip install conda
  2. pip install google

The error got resolved.

I had a similar import problem. I noticed that there was no __init__.py file in the root of the google package. So, I created an empty __init__.py and now the import works.

Use this both installation and then go ahead with your Python code:

pip install google-cloud
pip install google-cloud-vision

According to https://github.com/googleapis/google-api-python-client#installation, you need to install the google-api-python-client package:

pip install --upgrade google-api-python-client

I faced the same issue, and I was trying to import translate from google.cloud, but I kept getting the same error.

This is what I did

  1. pip install protobuf
  2. pip install google-cloud-translate

And to install the storage service from google google-cloud-storage, it should be installed separately.

Ref - https://cloud.google.com/python/

I could fix it by installing the following directly.

pip install google.cloud.bigquery
pip install google.cloud.storage

I found a similar error when I tried to access the bigquery from google.cloud.

from google.cloud import bigquery

The error was resolved after I installed the google.cloud from conda-forge community.

conda install -c conda-forge google-cloud-bigquery
  1. Close Anaconda/Spyder
  2. Open command prompt and run the below command
  3. conda update --all
  4. Start the app again and this time it should work.

Note - You need not have to uninstall/reinstall anything.

I got this from cloud service documentation:

pip install --upgrade google-cloud-translate

It worked for me!

Kindly executing these commands,

pip install google
pip install google-api-core

will definitely solve your problem.

What solved it for me was uninstalling Anaconda (in my case, Spyder), install the required google clients (google-api-python-client will do), then reinstall Anaconda.

This should solve it!

Kindly executing these commands

If you are using the python2 version:

  • pip install google
  • pip install google-api-core

If you are using the python3 version:

  • pip3 install google
  • pip3 install google-api-core

will definitely solve your problem.

I know its frustrating to make it done. Its not hit and try to be honest.

first step to setup google apis

pip install --upgrade google-api-python-client

second- look and read your DAG and see what is source/destination or other GCP platform you are using such as if you are taking data from bigquery then

pip install bigquery
or pip install xyz-google-stuff


For Python-Flask application.

If nothing helps,

  1. Uninstall flask (pip uninstall flask)
  2. Uninstall python from your machine
  3. Restart the machine and make sure uninstall is done properly
  4. Re-install python and flask again
  5. Run pip install --upgrade google-api-python-client
  6. Run your application

It should be working fine now.

I too had the same error while trying vision API

    from google.cloud import vision
import io
client = vision.ImageAnnotatorClient()

got no module named 'google'

so I added a line

import google

in such a way,

import google
from google.cloud import vision
import io
client = vision.ImageAnnotatorClient()

and it worked for me.:)