Config.yml - build fails when trying to install awscli AND awsebcli

Thank you in advance for your help! I need awscli to deploy ui to S3 and I need awsebcli to deploy my api to elastic beanstalk. The build is successful if I only do one or the other, but if I do both it errors out when installing the second one with unhelpful errors.

config.yml

version: 2
jobs:
  build:
    docker:
    - image: circleci/node:8.12
    working_directory: ~/project
    steps:
    - checkout
    - run:
        name: Installing dependencies for ui & api
        command: npm install
    - run:
        name: Unit tests for ui
        command: npm run test:ui
    - run:
        name: Unit tests for api
        command: npm run test:api
    - run:
        name: Install awscli
        command: |
          sudo apt install python-pip python-dev
          sudo pip install awscli
    - run:
        name: Deploy ui to s3
        command: npm run deploy:ui
    - run:
        name: Setup AWS credentials
        command: |
          mkdir ~/.aws && printf "[profile eb-cli]\naws_access_key_id = ${AWS_ACCESS_KEY_ID}\naws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/config
    - run:
        name: Install aws eb cli haha
        command: |
          sudo apt install python-pip python-dev
          sudo pip install awsebcli==3.14.11
    - run:
        name: Deploy api to elastic beanstalk
        command: npm run deploy:api
    - save_cache:
        key: dependency-cache-{{ checksum "package.json" }}
        paths:
        - node_modules

Error I’m getting:

#!/bin/bash -eo pipefail
sudo apt install python-pip python-dev
sudo pip install awsebcli==3.14.11
Reading package lists... Done


Building dependency tree       


Reading state information... Done

python-dev is already the newest version.
python-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
/usr/local/lib/python2.7/dist-packages/urllib3/contrib/socks.py:50: DependencyWarning: SOCKS support in urllib3 requires the installation of optional dependencies: specifically, PySocks.  For more information, see https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies
  DependencyWarning
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
    import requests, six
  File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 80, in <module>
    from . import utils
  File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/usr/lib/python2.7/dist-packages/requests/compat.py", line 94, in <module>
    from urllib3.packages.ordered_dict import OrderedDict
ImportError: No module named ordered_dict
Exited with code 1

Any ideas? Any and all help greatly appreciated!

This looks like your critical error:

I would tackle this by running apt-cache search pysocks on the server, to see what the dependency is called. I just did this on my local Mint installation, and got this:

$ apt-cache search pysocks
python-socks - Python 2 SOCKS client module
python3-socks - Python 3 SOCKS client module

Since you appear to be using Python 2, I would try amending your apt line to:

sudo apt install python-pip python-dev python-socks

Another option here is to move deployment related commands into its own job. Then you can use the cibuilds/aws image for that job, which has the AWS CLI and the EB CLI pre-installed.