9

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:

  1. pip install apiclient
  2. 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
1
  • importantly, when I try to import this in ipython , it work fine Commented Mar 14, 2016 at 8:55

5 Answers 5

21

Try this:

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

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:

pip install --force-reinstall google-api-python-client

Answer Source

Sign up to request clarification or add additional context in comments.

8 Comments

does it matter from which location in the file system I will run pip ?
I just ran these 2 pip commands and it says "requirement already met"
yes it matter if you use virtual environments. better to run pip in project directory. and for more information please click Answer Source. this will help you more.
/Users/nirregev/anaconda/bin/python /Users/nirregev/PycharmProjects/test/PrepareTrainingData.py Traceback (most recent call last): File "/Users/nirregev/PycharmProjects/test/PrepareTrainingData.py", line 3, in <module> from apiclient.discovery import build ImportError: No module named 'apiclient
look over here Due to an issue around in-place upgrades for Python packages, it's not possible to do an upgrade from version 1.2 to 1.3. Instead, setup.py attempts to detect this and prevents it. Simply remove the previous version and reinstall to fix this.
|
4

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 the apiclient in favor of the googleapiclient alias; which is an issue because some packages (e.g. airflow) still use that apiclient.discovery import.

Hope this helps.

Comments

1

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.

Comments

1

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.

Comments

0

I am on Mac, using brew's python, and this worked for me:

1 - As suggested by others, install the API client using pip:

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

2 - Make sure you are calling the library in your code as googleapiclient, and not as apiclient, which is deprecated.

3 - Tell Python to look for packages in the pip folder:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages

To make it permanent, add the above line to either your .profile or .bash_profile file in your $HOME.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.