python install module apiclient

回眸只為那壹抹淺笑 提交于 2019-11-27 18:19:56

问题


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:


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




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/35982655/python-install-module-apiclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!