Aws-cli: clidriver in version 1.13.0 is broken

Created on 29 Nov 2017  路  21Comments  路  Source: aws/aws-cli

After pip installing awscli==1.13.0 in a Docker container based from python:3.6.2, running any aws commands returns

Traceback (most recent call last):
  File "/usr/local/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ModuleNotFoundError: No module named 'botocore.history'

Reverted to awscli==1.12.0 and everything works fine.

Most helpful comment

This fixed it for me:

$ sudo -H pip install awscli --upgrade

All 21 comments

Sounds like your cli and botocore version are out of sync some how. For awscli v1.13.0 make sure you have at least botocore v1.8.3.

I'm having the exact same problem:

```[LOCAL][fcabral@droideka:~]$ sudo pip freeze | egrep '(awscli|boto|boto3|botocore)'
awscli==1.14.5
boto==2.48.0
boto3==1.4.8
botocore==1.8.9

```[LOCAL][fcabral@droideka:~]$ aws help
Traceback (most recent call last):
  File "/usr/local/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ImportError: No module named history

As @karimtabet said, reverting to 1.12.0 works.

Exact same error as @cabral404, using:

aws-cli/1.14.6
botocore/1.8.12
Python/2.7.12

Got same problem when run with my user, if sudo is used aws cli runs fine, seems it has permission problems when installed from packages or pip.

My workaround looks like this:

  • Remove aws cli from pip with pip uninstall awscli
    or
  • Remove remove aws-cli packages (like packman -R aws-cli)
  • Then use aws bundle
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
./awscli-bundle/install -b ~/bin/aws
export PATH=~/bin:$PATH

More info are here http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html#install-bundle-user

While reverting to an earlier version may work, newer versions not working due to imports failing sounds like an issue with how the awscli package was installed or how python packages in general are managed on your system. In this case there's probably another version of botocore somewhere that's taking precedence over the one being displayed in the output of pip freeze.

As @Danpiel mentions removing all other installation methods and using a bundled installer is a possible solution as that uses an isolated virtualenv to run the aws cli.

For anybody still running into this please provide the following:
1) What operating system are you using?
2) How did you install the awscli package?
3) How did you attempt update the awscli package?

This fixed it for me:

$ sudo -H pip install awscli --upgrade

aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text --region us-east-1
Traceback (most recent call last):
  File "/usr/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ImportError: No module named history

I am also facing same issue.

same issue as @optimisticanshul
aws version: awscli-1.14.19
botocore: botocore-1.8.23
python: Python 2.7.13

Workaround:

  1. pip uninstall boto3 -y
  2. pip uninstall boto -y
  3. pip uninstall botocore -y
  4. pip install botocore --upgrade

Result aws works

I am facing similar issue. Only difference being that when I try and access it as root user, I am getting the error, but when accessing it as ec2-user, it works just fine.

Output as ec2-user

[ec2-user@ip-x-x-x-x ~]$ aws route53 change-resource-record-sets --hosted-zone-id $PrivateHostedZoneId --change-batch file:///home/ec2-user/change.json
{
    "ChangeInfo": {
        "Status": "PENDING",
        "Comment": "Create route53 DNS entry at instance boot up",
        "SubmittedAt": "2018-01-17T12:30:45.534Z",
        "Id": "/change/C1IG3ETCO6MGVW"
    }
}

Output as root user

[root@ip-x-x-x-x ec2-user]# aws route53 change-resource-record-sets --hosted-zone-id $PrivateHostedZoneId --change-batch file:///home/ec2-user/change.json
Traceback (most recent call last):
  File "/usr/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ImportError: No module named history

aws-cli: 1.14.9
Python: 2.7.12
Linux: 4.9.76-3.78.amzn1.x86_64
botocore: 1.8.13

Also seeing the same problem.

Linux: Arch Linux
Python: 3.6.4
aws-cli 1.14.40-1
botocore: 1.8.44-1

Tried to upgrade botocore via pip, unsuccessfully so far.

Update: I also tried sudo pip install awscli --force-reinstall --upgrade which was mentioned in #641 but that didn't help either.

Same problem here using Windows:

platform: win32
python: 3.5.2
awscli: 1.14.41
botocore: 1.8.45

I have tried the suggested workarounds above, with the uninstall and reinstall of awscli and botocore, and I'm still getting the message:

  File "C:\python\Python3\Scripts\aws.cmd", line 50, in <module>
    import awscli.clidriver
ImportError: No module named awscli.clidriver

If you have the CLI installed via any mechanism other than pip (such as a linux package manager) then you will need to uninstall there too to make sure to clean out your system before you reinstall. For Windows I highly recommend using the installer we provide here

same here but fixed with upgrades.
failed ones

boto (2.48.0)
boto3 (1.4.7)
botocore (1.7.1)
pip install --upgrade boto3
pip install --upgrade botocore
pip install --upgrade awscli

```
aws ecs list-container-instances --cluster my_ecs_cluster
{
"containerInstanceArns": [

...
]
}

Still getting error with most current versions:
awscli==1.14.53
boto==2.48.0
boto3==1.6.6
botocore==1.9.6

Command: aws ecr get-login --region $AWS_DEFAULT_REGION
Image: Ubuntu - aws/codebuild/docker:17.09.0

Traceback (most recent call last):
File "/usr/local/bin/aws", line 19, in
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in
from botocore.history import get_global_history_recorder
ImportError: No module named history

Found a working solution:
awscli==1.11.157
boto3==1.6.7
botocore==1.9.7

Looks like a fix was applied and boto3 and botocore versions were updated. Whatever updates they did, it seems to have fixed the problem.

It looks like the was cannot parse the config file. I resolved the issue by creating a new ~/.aws/config file.

I had the same issue on CentOS installing with yum. I removed the packages with yum and installed awscli with pip and now everything works fine.

For those installing from centos 7 with epel, awscli was removed from epel and included in centos base repo. however the dependencies changed, just remove the following packages (if nothing else uses it)

python2-s3transfer python-colorama python2-botocore python2-rsa

then reinstall from centos-base repo

Closing out old issue. As mentioned, the issue is due to older versions of botocore being used with the CLI. As long as you're installing via pip or any other supported installation methods, you will get a working version of the CLI.

Remove the botocore packege
pip uninstall botocore

install awscli again
pip install awscli

Now its works for me

sudo -H pip install awscli --upgrade

@mariosotil you saved us!

Was this page helpful?
0 / 5 - 0 ratings