DEV Community

Rimpal Johal for AWS Community Builders

Posted on

Install Python AWS SDK Boto3

This post is about installing AWS SDK boto3 on Mac. Python comes pre-installed on Mac OS so it is easy to start using it. However, to take advantage of the latest versions of Python, you will need to download and install newer versions alongside the system ones. Note that Python installers are available for the latest Python 3 and Python 2 releases that will work on all Macs that run Mac OS X 10.5 and later.

Follow the steps below to install Python AWS SDK boto3 on MacBook.

  1. Check the version of Python on your Mac machine first

      @MacBook-Pro ~ % python --version
      Python 2.7.16
    
  2. To install AWS SDK boto3 , it is recommended to upgrade the Python to latest version

  3. Since the Python is system installed here so we need to install the latest version of Python and not upgrade the Python. Note that any attempt to upgrade the Python will give the error as " Error: Python not installed"

    command to use is

     brew install python
    
  4. Once the latest version is installed on your Mac, check the installed python by the command as below

    @MacBook-Pro ~ % ls -ltra /usr/local/bin/python*   
    

    One can see the output as below from the above command

    lrwxr-xr-x  1 rimpaljohal  admin  38 16 Jul 09:27 /usr/local/bin/python3 -> ../Cellar/python@3.9/3.9.6/bin/python3
    lrwxr-xr-x  1 rimpaljohal  admin  45 16 Jul 09:27 /usr/local/bin/python3-config -> ../Cellar/python@3.9/3.9.6/bin/python3-config
    lrwxr-xr-x  1 rimpaljohal  admin  40 16 Jul 09:27 /usr/local/bin/python3.9 -> ../Cellar/python@3.9/3.9.6/bin/python3.9
    lrwxr-xr-x  1 rimpaljohal  admin  47 16 Jul 09:27 /usr/local/bin/python3.9-config -> ../Cellar/python@3.9/3.9.6/bin/python3.9-config
    lrwxr-xr-x  1 rimpaljohal  admin  24 16 Jul 10:03 /usr/local/bin/python -> /usr/local/bin/python3.9
    

    After confirming the python version, change the default python symlink to the version one want to use from above.

    Command below will create the symbolic link for pointing the default Python path to the latest installed version of the Python

      ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python
    
    
  5. Close the terminal and reopen the new session. Check the version of Python now

      Python --version
    
      @MacBook-Pro ~ % Python --version
      Python 3.9.6
    
    

    Here, I have updated my Mac to the latest Python Version. Now, I will move to install Boto3 on my Mac

  6. Install the pip in the first place

    sudo easy_install pip
    
    Searching for pip
    Best match: pip 21.1.3
    Processing pip-21.1.3-py2.7.egg
    pip 21.1.3 is already the active version in easy-  install.pth
    Installing pip script to /usr/local/bin
    Installing pip2.7 script to /usr/local/bin
    Installing pip2 script to /usr/local/bin
    
    
  7. Once the pip is installed then install boto3

    @MacBook-Pro ~ % pip3 install boto3
    Successfully installed boto3-1.18.0 botocore-1.21.0    jmespath-0.10.0 python-dateutil-2.8.2 s3transfer-0.5.0 six-1.16.0 urllib3-1.26.6
    
  8. After boto3 is installed then install awscli

    @MacBook-Pro ~ % pip3 install awscli
    
    Successfully installed PyYAML-5.4.1 awscli-1.20.0 colorama-0.4.3 docutils-0.15.2 pyasn1-0.4.8 rsa-4.7.2
    
  9. In the final step configure awscli with and you are all ready to use Python AWS SDK boto3 on your Mac super machine!!

Some quick commands

@MacBook-Pro ~ % which pip
/usr/local/bin/pip
Enter fullscreen mode Exit fullscreen mode
@MacBook-Pro ~ % pip3 --version
pip 21.1.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Enter fullscreen mode Exit fullscreen mode

Happy Coding!!

Top comments (0)