python install module apiclient

2020-02-10 06:55发布

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

5条回答
来,给爷笑一个
2楼-- · 2020-02-10 07:17

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.

查看更多
3楼-- · 2020-02-10 07:20

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.

查看更多
Root(大扎)
4楼-- · 2020-02-10 07: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

查看更多
别忘想泡老子
5楼-- · 2020-02-10 07:23

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.

查看更多
迷人小祖宗
6楼-- · 2020-02-10 07:25

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.

查看更多
登录 后发表回答