Why aws cli command fails with Traceback "ImportError: No module named history." ?

Solution Verified - Updated -

Issue

  • For RHEL 7 the aws command from awscli package fails for error.

    # aws --version
    Traceback (most recent call last):
     File "/usr/bin/aws", line 19, in <module>
       import awscli.clidriver
     File "/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 18, in <module>
       import botocore.session
    ImportError: No module named botocore.session
    
    OR 
    
    # aws --version
    Traceback (most recent call last):
     File "/usr/bin/aws", line 19, in <module>
       import awscli.clidriver
     File "/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 26, in <module>
       from botocore.history import get_global_history_recorder
    ImportError: No module named history.
    
  • For RHEL 8 the aws command from awscli package fails for error.

    aws --version
    Traceback (most recent call last):
     File "/usr/bin/aws", line 27, in <module>
       sys.exit(main())
     File "/usr/bin/aws", line 23, in main
       return awscli.clidriver.main()
     File "/usr/lib/python3.6/site-packages/awscli/clidriver.py", line 70, in main
       driver = create_clidriver()
     File "/usr/lib/python3.6/site-packages/awscli/clidriver.py", line 80, in create_clidriver
       event_hooks=session.get_component('event_emitter'))
     File "/usr/lib/python3.6/site-packages/awscli/plugin.py", line 46, in load_plugins
       modules = _import_plugins(plugin_mapping)
     File "/usr/lib/python3.6/site-packages/awscli/plugin.py", line 63, in _import_plugins
       module = __import__(path, fromlist=[module])
     File "/usr/lib/python3.6/site-packages/awscli/handlers.py", line 27, in <module>
       from awscli.customizations.cloudformation import initialize as cloudformation_init
     File "/usr/lib/python3.6/site-packages/awscli/customizations/cloudformation/__init__.py", line 13, in <module>
       from awscli.customizations.cloudformation.package import PackageCommand
     File "/usr/lib/python3.6/site-packages/awscli/customizations/cloudformation/package.py", line 27, in <module>
       from awscli.customizations.s3uploader import S3Uploader
     File "/usr/lib/python3.6/site-packages/awscli/customizations/s3uploader.py", line 23, in <module>
       from s3transfer.manager import TransferManager
    ModuleNotFoundError: No module named 's3transfer
    

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content