Warm tip: This article is reproduced from stackoverflow.com, please click

Googleapiclient and python3

发布于 2020-03-29 21:00:34

I wrote a basic Python 3 script that uses the Google Sheets API. It works on a system that defaults to Python 3 (Arch). I'm trying to run the same script on an Ubuntu 14.04 system, but I'm unable to load the apiclient library. I installed with the recommended pip install --upgrade google-api-python-client But I noticed I can only load the library in python 2.

Here's what I'm observing:

~ $ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from googleapiclient import discovery
>>> quit()
~ $ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from googleapiclient import discovery
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'googleapiclient'

Any advice?

Questioner
isuldor
Viewed
55
Dineshkarthik Raveendran 2017-11-22 14:54

The Googleapiclient is installed only on python2 (Which i guess is your default python version) not python3.

Install Googleapiclient in python3 env using the following:

pip3 install --upgrade google-api-python-client