如何通过终端安装 Google API 客户端库

How to Install Google APIs Client Library via terminal

我尝试通过终端安装 Google API 客户端库并得到以下结果:

$ sudo pip install google-api-python-client

The directory '/home/masterqiao/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/masterqiao/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: google-api-python-client in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: httplib2<1dev,>=0.9.2 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: oauth2client<5.0.0dev,>=1.5.0 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: uritemplate<4dev,>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: six<2dev,>=1.6.1 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: pyasn1>=0.1.7 in /usr/local/lib/python2.7/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Requirement already satisfied: pyasn1-modules>=0.0.5 in /usr/local/lib/python2.7/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Requirement already satisfied: rsa>=3.1.4 in /usr/local/lib/python2.7/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)

试试这个

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

你可以参考这个 or official documentation

您可以通过两种方式完成

选项 1:

varad@adithya-pc /tmp/venv/testPythonStacks $ source bin/activate
(testPythonStacks) varad@adithya-pc /tmp/venv/testPythonStacks $ pip install --upgrade google-api-python-client
Collecting google-api-python-client
  Downloading google_api_python_client-1.6.2-py2.py3-none-any.whl (52kB)
    100% |████████████████████████████████| 61kB 366kB/s 
Requirement already up-to-date: six<2dev,>=1.6.1 in ./lib/python2.7/site-packages (from google-api-python-client)
Collecting uritemplate<4dev,>=3.0.0 (from google-api-python-client)
  Downloading uritemplate-3.0.0-py2.py3-none-any.whl
Collecting oauth2client<5.0.0dev,>=1.5.0 (from google-api-python-client)
  Downloading oauth2client-4.0.0-py2.py3-none-any.whl (184kB)
    100% |████████████████████████████████| 194kB 1.0MB/s 
Collecting httplib2<1dev,>=0.9.2 (from google-api-python-client)
  Downloading httplib2-0.10.3.tar.gz (204kB)
    100% |████████████████████████████████| 204kB 908kB/s 
Collecting rsa>=3.1.4 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
  Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
    100% |████████████████████████████████| 51kB 1.9MB/s 
Collecting pyasn1-modules>=0.0.5 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
  Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
  Downloading pyasn1-0.2.3-py2.py3-none-any.whl (53kB)
    100% |████████████████████████████████| 61kB 1.7MB/s 
Building wheels for collected packages: httplib2
  Running setup.py bdist_wheel for httplib2 ... done
  Stored in directory: /home/varad/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0c
Successfully built httplib2
Installing collected packages: uritemplate, pyasn1, rsa, httplib2, pyasn1-modules, oauth2client, google-api-python-client
Successfully installed google-api-python-client-1.6.2 httplib2-0.10.3 oauth2client-4.0.0 pyasn1-0.2.3 pyasn1-modules-0.0.8 rsa-3.4.2 uritemplate-3.0.0
t

选项 2:

1. wget https://pypi.python.org/packages/e8/04/4bb1672918e4fc6d6a8201bdaf986b9fb4763f2a47b11496186dbbbd40ce/google-api-python-client-1.6.2.tar.gz#md5=5efd35416d57e6571276a52f81d26bc7
2. tar -xvf google-api-python-client-1.6.2.tar.gz
3. cd google-api-python-client-1.6.2
4. python setup.py build
5. sudo python setup.py install