Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name api - Error Configuring aws_cli on centos 7

I successfully installed aws using pip install awscli --upgrade --user. However, when I'm trying to aws configure or aws --version, I'm getting following error

Traceback (most recent call last):
  File "/bin/aws", line 9, in <module>
    load_entry_point('aws==0.2.5', 'console_scripts', 'aws')()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/site-packages/aws/main.py", line 7, in <module>
    from fabric import api as fab
ImportError: cannot import name api

My System details are as follows

Python 2.7.5
pip 18.0 from /usr/lib/python2.7/site-packages/pip (python 2.7)
Operating System: CentOS Linux 7 (Core)
Kernel: Linux 3.10.0-862.9.1.el7.x86_64
Architecture: x86-64

Path Variable is set to /usr/local/rvm/gems/ruby-2.4.1/bin:/usr/local/rvm/gems/ruby-2.4.1@global/bin:/usr/local/rvm/rubies/ruby-2.4.1/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib:/opt/gradle/gradle-4.7/bin:/usr/local/rvm/bin:/root/bin

like image 217
sulabh chaturvedi Avatar asked Aug 11 '18 05:08

sulabh chaturvedi


People also ask

How to install AWS CLI on RHEL 8?

In order to install aws cli on rhel 8 follow these steps install python3-pip pip3 install awscli --upgrade --user confirm it by this aws --version if you want to check out docs on installation.

What is the best way to configure aws cli?

For general use, the aws configure command is the fastest way to set up your AWS CLI installation. When you type this command, the AWS CLI prompts you for four pieces of information (access key, secret access key, AWS Region, and output format).

Where is AWS config file in Linux?

The CLI configuration file – This is another file that is updated when you run the command aws configure. The file is located at ~/.aws/config on Linux, macOS, or Unix, or at C:\Users\USERNAME\.aws\config on Windows.

What version of python do I need to run AWS AWS?

You need six version > 1.8.0. Show activity on this post. Show activity on this post. Show activity on this post. I had to update Python On FreeBSD I ran. pkg update pkg upgrade Then I was able to run AWS aws --version Show activity on this post. I had to remove the anaconda bin from my $PATH in my .bashrc.


Video Answer


2 Answers

The aws package in PyPI is not AWS's official CLI client but rather an older unmaintained library that used to interface with AWS and is now broken. AWS's official CLI client is awscli. Therefore if you pip install aws instead of pip install awscli you will run into the issue above.

The solution is to first run pip uninstall aws then run pip install awscli.

like image 95
CognizantApe Avatar answered Oct 19 '22 03:10

CognizantApe


Error with import if fabric submodules. Commented from fabric import .. statements and added import fabric. Not sure, if this is originally an issue but, resolved my problem. Please refer my comment on my question.

like image 39
sulabh chaturvedi Avatar answered Oct 19 '22 02:10

sulabh chaturvedi