77

I installed Python 3.5. I ran the pip install google command and verified the modules. Google was present.

I installed Anaconda 3.5 and tried to run z sample code. But I'm getting the import error. Please find the screen shot attached. What am I missing? Do I have to link my Spyder to Python installation directory in some way? Why is Spyder unable to google module?

My Python installation directory: C:\Users\XXX\AppData\Local\Programs\Python\Python35

Enter image description here

Enter image description here

My scenario is a bit different and I could not find a solution from similar posts here.

Pavel Fedotov
  • 301
  • 3
  • 15
redwolf_cr7
  • 1,545
  • 4
  • 21
  • 29

15 Answers15

111

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
Saber
  • 2,082
  • 1
  • 21
  • 38
39

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

pip install google-cloud
pip install google-cloud-vision
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Darshit Shah
  • 579
  • 4
  • 5
22

I could fix it by installing the following directly.

pip install google.cloud.bigquery
pip install google.cloud.storage
Ratnesh Sharma
  • 397
  • 3
  • 7
8

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/

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Arkil Shaikh
  • 192
  • 1
  • 8
7

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
redwolf_cr7
  • 1,545
  • 4
  • 21
  • 29
  • 1
    Thank you! Actually, The key of the solution is Re-install Anaconda only and install it after the cudnn! :P – Mohammad Javad May 17 '19 at 23:39
  • what does this: "Open Anaconda prompt and point it to Anaconda/Scripts" mean, what are the steps to reproduce this action? – joe hoeller Apr 21 '20 at 08:14
  • I have the same question. What does "point it to Anaconda/Scripts" mean? I had opened my Anaconda prompt but did not know what to do to "point it to Anaconda/Scripts". – CanaryTheBird Jul 05 '21 at 02:20
6

I solved the problem in this way:

  1. sudo pip install conda
  2. pip install google

The error got resolved.

Pavel Fedotov
  • 301
  • 3
  • 15
Chenxi Rao
  • 69
  • 1
  • 2
5

I got this from cloud service documentation:

pip install --upgrade google-cloud-translate

It worked for me!

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Amol Buch
  • 51
  • 1
  • 2
4

Kindly executing these commands,

pip install google
pip install google-api-core

will definitely solve your problem.

sajjad3277
  • 41
  • 1
2

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
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
smsivaprakaash
  • 1,404
  • 13
  • 10
0

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.

Ferenc Pal
  • 114
  • 1
  • 6
  • 2
    This did not work for me (python 3.7, macOS 10.13.6) – Jonathan Cross Nov 03 '18 at 18:02
  • Verify first whether you have package installed through PIP or not? If Yes, then please check the Directory path and if not then you have to again use the above 2 commands to install it – Darshit Shah Dec 04 '18 at 17:57
0

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!

Yaakov Bressler
  • 6,210
  • 2
  • 31
  • 51
0

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

0

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.

Hack_it
  • 1
  • 1
-1
  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.

Mohan. A
  • 409
  • 4
  • 13
-2

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.