aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

clidriver in version 1.13.0 is broken

Open karimtabet opened this issue 9 years ago • 21 comments

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.

karimtabet avatar Nov 29 '17 11:11 karimtabet

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.

joguSD avatar Nov 29 '17 17:11 joguSD

I'm having the exact same problem:

awscli==1.14.5
boto==2.48.0
boto3==1.4.8
botocore==1.8.9
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.

cabral404 avatar Dec 07 '17 13:12 cabral404

Exact same error as @cabral404, using:

aws-cli/1.14.6 botocore/1.8.12 Python/2.7.12

mherger avatar Dec 13 '17 09:12 mherger

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

Danpiel avatar Dec 13 '17 11:12 Danpiel

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?

joguSD avatar Dec 20 '17 21:12 joguSD

This fixed it for me:

$ sudo -H pip install awscli --upgrade

mariosotil avatar Dec 28 '17 17:12 mariosotil

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.

sharmaansh21 avatar Jan 08 '18 12:01 sharmaansh21

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

jfairchild avatar Jan 08 '18 16:01 jfairchild

Workaround:

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

Result aws works

jfairchild avatar Jan 08 '18 16:01 jfairchild

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

hapx101 avatar Jan 17 '18 12:01 hapx101

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.

milgner avatar Feb 16 '18 14:02 milgner

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

authalic avatar Feb 19 '18 17:02 authalic

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

JordonPhillips avatar Feb 20 '18 23:02 JordonPhillips

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": [

...
    ]
}

hflamboauto1 avatar Mar 06 '18 13:03 hflamboauto1

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.

rubelw avatar Mar 12 '18 18:03 rubelw

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

xtreamgit avatar Apr 05 '18 00:04 xtreamgit

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.

mdeboer avatar May 23 '18 09:05 mdeboer

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

gfa avatar May 23 '18 10:05 gfa

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.

jamesls avatar Jun 20 '18 19:06 jamesls

Remove the botocore packege pip uninstall botocore

install awscli again pip install awscli

Now its works for me

rajesh6752 avatar Jul 02 '20 08:07 rajesh6752