구글 drive api 사용기

구글 drive api 사용기

python
구글 drive api 홈페이지 : https://developers.google.com/drive/
죄측 메뉴 Quickstart > python : https://developers.google.com/drive/quickstart-python

비디오
https://developers.google.com/drive/quickstart-python#optional_view_a_quickstart_video

1단계 : Enable the Drive API
1. Create an API project in the Google APIs Console.
2. Select the Services tab in your API project, and enable the Drive API.
3. Select the API Access tab in your API project, and click Create an OAuth 2.0 client ID.
4. In the Branding Information section, provide a name for your application (e.g. “Drive Quickstart Sample”), and click Next. Providing a product logo is optional.
5, In the Client ID Settings section, do the following:
a. Select Installed application for the Application type
b. Select Other for the Installed application type.
c. Click Create Client ID.
6. In the API Access page, locate the section Client ID for installed applications and note or copy the two pieces of information you’ll need later to run the sample: the Client ID and the Client Secret.

그림

2단계 : Install the Google Client Library
To install the Google API Python Client on a system, you must use either the pip command or easy_install command.
easy_install –upgrade google-api-python-client
pip install –upgrade google-api-python-client
If you need to access the Google API Python Client from a Google App Engine project, you can follow the instructions here.

근데 서버에 easy_install이 없다..(pip도..)

easy_install 설치..(귀찮아서 yum으로)

setuptools 설치

]# yum install python-setuptools

easy_install으로 google-api-python-client 설치

]# easy_install --upgrade google-api-python-client
Searching for google-api-python-client
Reading http://cheeseshop.python.org/pypi/google-api-python-client/
Reading http://code.google.com/p/google-api-python-client/
Reading http://cheeseshop.python.org/pypi/google-api-python-client/1.0
Best match: google-api-python-client 1.0
Downloading http://pypi.python.org/packages/source/g/google-api-python-client/google-api-python-client-1.0.zip#md5=3db5053e17a531f971a1835819d3427e
Processing google-api-python-client-1.0.zip
Running google-api-python-client-1.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-xmYFn9/google-api-python-client-1.0/egg-dist-tmp-q7WIyE
warning: no files found matching '*.json' under directory 'apiclient'
zip_safe flag not set; analyzing archive contents...
Adding google-api-python-client 1.0 to easy-install.pth file
Installing enable-app-engine-project script to /usr/bin

Installed /usr/lib/python2.4/site-packages/google_api_python_client-1.0-py2.4.egg
Processing dependencies for google-api-python-client
Searching for simplejson
Reading http://cheeseshop.python.org/pypi/simplejson/
Reading http://github.com/simplejson/simplejson
Reading http://cheeseshop.python.org/pypi/simplejson/3.0.7
Best match: simplejson 3.0.7
Downloading http://pypi.python.org/packages/source/s/simplejson/simplejson-3.0.7.tar.gz
Processing simplejson-3.0.7.tar.gz
Running simplejson-3.0.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-M4SdT5/simplejson-3.0.7/egg-dist-tmp-O88uzb
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1670, in main
    with_ei_usage(lambda:
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1659, in with_ei_usage
    return f()
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1674, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/lib64/python2.4/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/lib64/python2.4/distutils/dist.py", line 946, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 211, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 446, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 473, in install_item
    self.process_distribution(spec, dist, deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 518, in process_distribution
    distros = WorkingSet([]).resolve(
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 481, in resolve
    dist = best[req.key] = env.best_match(req, self, installer)
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 717, in best_match
    return self.obtain(req, installer) # try and download/install
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 729, in obtain
    return installer(requirement)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 446, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 471, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 655, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 930, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 919, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 26, in run_setup
    DirectorySandbox(setup_dir).run(
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 63, in run
    return func()
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 29, in </lambda><lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 14
    with open('README.rst', 'r') as f:
            ^
SyntaxError: invalid syntax
]#

에러다..ㅠㅠ

아래 부분으로 봐선 2.4버전도 지원하는 것같은데..

Installed /usr/lib/python2.4/site-packages/google_api_python_client-1.0-py2.4.egg

왜 에러 일까..ㅠㅠ

simplejson-3.0.7/setup.py
이 패키지가 문제인듯 한데..

좀 더 찾아봐야 할듯..(5분이면 된데서 해봤는데.. 지금 이거 볼 시간이 없어서 pass~)

This entry was posted in Python/Ruby/Perl, Util/Tools and tagged , , , , , , . Bookmark the permalink.

댓글 남기기