Tuesday, May 5, 2015

Install Python 2.7( or 3.3) on CentOS 6.x, install PIP, and boto (python sdk for AWS IaaC work)


-        CentOS comes with python 2.6.

-        Instructions for getting boto on a different python version (e.g. 2.7.9). Currently boto is being upgraded to support python 3.3+.

o   Ensure that you are firing the cmds in a privileged account

 

·        Install as root (or sudo)

·        Install python 2.7.9

o   Download appropriate python version

o   Commands:

cd /tmp/


gunzip Python-2.7.9.tgz

tar -xvf Python-2.7.9.tar

cd Python-2.7.9/

yum groupinstall "Development tools"

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

cat /etc/ld.so.conf

./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"

make && make altinstall

/usr/local/bin/python2.7

Python 2.7.9 (default, May  5 2015, 09:19:07)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>

·        Install PIP :-


o   Commands

cd /tmp/


python2.7 ez_setup.py

easy_install-2.7 pip

·        Install boto:-

  • Install boto:-
    • pip install boto

[tom@localhost ~]$ python2.7

Python 2.7.9 (default, May  5 2015, 09:19:07)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import boto

>>> boto.connect_s3()

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/local/lib/python2.7/site-packages/boto/__init__.py", line 141, in connect_s3

    return S3Connection(aws_access_key_id, aws_secret_access_key, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 190, in __init__

    validate_certs=validate_certs, profile_name=profile_name)

  File "/usr/local/lib/python2.7/site-packages/boto/connection.py", line 569, in __init__

    host, config, self.provider, self._required_auth_capability())

  File "/usr/local/lib/python2.7/site-packages/boto/auth.py", line 987, in get_auth_handler

    'Check your credentials' % (len(names), str(names)))

boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials

>>>

 

P.S: The NoAuthHandlerFound is because proper AWS key/secret hasn’t been set. (http://boto.readthedocs.org/en/latest/getting_started.html )

No comments:

Post a Comment