New to python, and trying to install a module "apiclient" since my ide pycharm does not recognize that import:
from apiclient.discovery import build
what I tried:
- pip install apiclient
- download manually the package from
https://developers.google.com/api-client-library/python/start/installation#system-requirements then I extracted it into
/Users/nirregev/anaconda/bin/google-api-python-client-1.5.0
and ran this on my mac terminal python setup.py install but still pycharm does not recognize this module. According to pycharm I have the following interpreters installed:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
/Users/nirregev/anaconda/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
I am on Mac, using brew's python, and this worked for me:
1 - As suggested by others, install the API client using pip:
2 - Make sure you are calling the library in your code as
googleapiclient
, and not asapiclient
, which is deprecated.3 - Tell Python to look for packages in the pip folder:
To make it permanent, add the above line to either your
.profile
or.bash_profile
file in your$HOME
.If you have got both python 2 and python 3 and you're trying to use python 2 for this purpose try the following:
sudo pip2 install google-api-python-client==1.5.3
. This worked for me.Try this:
OR
Make sure you only have google-api-python-client installed. If you have apiclient installed, it will cause a collision. So, run the following:
Answer Source
I ran into this problem and had a tough time figuring it out. In the end, this worked for me:
pip install google-api-python-client==1.5.3
Before doing this, I had version 1.6.2 installed. What I think is going on is that later versions of
google-api-python-client
dropped theapiclient
in favor of thegoogleapiclient
alias; which is an issue because some packages (e.g. airflow) still use thatapiclient.discovery
import.Hope this helps.
If you have python3 installed somewhere and you are to install apiclient, it may be installing it in your python3 directory. I had the same problem and when I uninstalled python3 my program ran smoothly.