Python dependencies install, but still get ImportError

I have a python script that I have been using in a few builds. So far they have all worked, but one has raised an ImportError.

The script uses boto3. So the circle.yml is:

machine:
    services:
        - docker

dependencies:
    pre:
        - sudo pip install boto3

deployment:
    dev:
        branch: dev
        commands:
            - python wait_for_ok.py my-env

But when it executes:

Traceback (most recent call last):
  File "ci_cd/wait_for_ok.py", line 7, in <module>
    import boto3
ImportError: No module named boto3

I can’t think of why this has happened as all the builds I have set-up are the same, but so far this one is failing.

I managed to resolve this issue. I added the python version and removed sudo from the pip install. circle.yml looked as follows:

machine:
    services:
        - docker
    python:
        version: 2.7.11

dependencies:
    pre:
        - pip install boto3

deployment:
    dev:
        branch: dev
        commands:
            - python wait_for_ok.py my-env