资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

AWSSDKPython

安装pip

在沧县等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都做网站、网站制作 网站设计制作按需开发,公司网站建设,企业网站建设,品牌网站制作,网络营销推广,外贸网站建设,沧县网站建设费用合理。

[root@xxxxxx ~]# python get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 597kB/s
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/66/e8/570bb5ca88a8bcd2a1db9c6246bb66615750663ffaaeada95b04ffe74e12/setuptools-40.2.0-py2.py3-none-any.whl (568kB)
    100% |████████████████████████████████| 573kB 5.1MB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
    100% |████████████████████████████████| 51kB 8.4MB/s
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-18.0 setuptools-40.2.0 wheel-0.31.1

安装virtualenv

[root@xxxxxx ~]# pip install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 4.8MB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.0.0

创建测试的虚拟python环境

[root@xxxxxx virtualenv]# virtualenv testenv

New python executable in /usr/local/python-2.7.15/virtualenv/testenv/bin/python

Installing setuptools, pip, wheel...done.

加载虚拟python环境

[root@xxxxxx virtualenv]# source testenv/bin/activate

(testenv) [root@xxxxxx virtualenv]# python -V

Python 2.7.5

退出虚拟python环境

(testenv) [root@xxxxxx virtualenv]# deactivate

使用Python SDK虚拟环境调动AWS命令

[root@ec2t-dbaadmin-01 rmp]# virtualenv dhchen_env

New python executable in /data/01/local/rmp/dhchen_env/bin/python2

Also creating executable in /data/01/local/rmp/dhchen_env/bin/python

Installing setuptools, pip, wheel...done.

安装boto3软件

(dhchen_env) [root@ec2t-dbaadmin-01 dhchen_env]# pip install boto3

.......

Installing collected packages: urllib3, jmespath, six, python-dateutil, docutils, botocore, futures, s3transfer, boto3

Successfully installed boto3-1.9.4 botocore-1.12.4 docutils-0.14 futures-3.2.0 jmespath-0.9.3 python-dateutil-2.7.3 s3transfer-0.1.13 six-1.11.0 urllib3-1.23

配置AWS key

(dhchen_env) [root@ec2t-dbaadmin-01 dhchen_env]# aws configure

AWS Access Key ID [None]: xxx

AWS Secret Access Key [None]: xxx

Default region name [us-west-2]:

Default output format [None]:

(dhchen_env) [root@ec2t-dbaadmin-01 .aws]# cat ~/.aws/credentials

[default]

aws_access_key_id = xxx

aws_secret_access_key = xxx

(dhchen_env) [root@ec2t-dbaadmin-01 .aws]# cat ~/.aws/config

[default]

region = us-west-2

测试AWS S3调用

(dhchen_env) [root@ec2t-dbaadmin-01 .aws]# python

>>> import boto3

>>> s3 = boto3.client('s3')

>>> response = s3.list_buckets()

>>> buckets = [bucket['Name'] for bucket in response['Buckets']]

>>> print("Bucket List: %s" % buckets)

参考链接

https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html


当前文章:AWSSDKPython
本文链接:http://cdkjz.cn/article/jicodd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220