awscli fails to work: No module named 'awscli&

2019-04-18 00:57发布

I am trying to install awscli using pip3 on Linux Mint 17.2 Rafaela.

I am getting the error:

Traceback (most recent call last):
  File "/home/jonathan/.local/bin/aws", line 19, in <module>
    import awscli.clidriver
ImportError: No module named 'awscli'

These are the steps I am taking, following the aws installation guide:

sudo pip install awscli --upgrade --user

everything seems to install fine.

adding to my .bashrc

export PATH=~/.local/bin:$PATH

then

source ~/.bashrc

then i try the command

aws --version

and i get

Traceback (most recent call last):
  File "/home/jonathan/.local/bin/aws", line 19, in <module>
    import awscli.clidriver
ImportError: No module named 'awscli'

Can anyone help with this?

EDIT: For anyone visiting this question. There is no way I can test any of these answers because I have since removed this OS and installed Ubuntu. Also I have no need for awscli anymore.

10条回答
趁早两清
2楼-- · 2019-04-18 01:01

I created the same situation by first did pip install awscli, then did sudo pip install awscli. After running

sudo pip uninstall awscli 
sudo pip install awscli

I still got problems. I have to manually remove the $HOME/.local directory with sudo rm -rf .local

查看更多
Evening l夕情丶
3楼-- · 2019-04-18 01:06

I had the same issue. I realized that awscli wasn't installed in /usr/local/lib/python3.5 but instead in /.local/usr . So i uninstalled awscli using

sudo pip3 uninstall awscli

and just used this

sudo pip3 install awscli

that solved the issue for me. Now aws --version is working perfectly. Also make sure you remove all the dependencies of awscli which were installed in the /.local folder, you can simply uninstall all of them, and then run the above command.

查看更多
祖国的老花朵
4楼-- · 2019-04-18 01:09

In my case, I must have ran a pip command with sudo that I shouldn't have, causing root to be the owner of various subdirectories of ~/.local/ which should be owned by me. Running sudo -H aws --version would work, but aws --version would not.

Running this to correct the owner fixed a lot of my problems:

sudo chown -R $USER ~/.local
查看更多
对你真心纯属浪费
5楼-- · 2019-04-18 01:12

I tried installing hard with many ways. Following what worked for me. Uninstall aws-cli using pip. it can be pip3 or just pip. Ensure not to use sudo while installing back. Do following:

  • Uninstall already installed one using

sudo pip uninstall awscli

  • Install back using without sudo and this time it should work.

pip install awscli

Now check aws-cli installation successful or not using below

aws --version

Shows below result if works well. In my case it shows as:

aws-cli/1.16.60 Python/2.7.15+ Linux/4.18.0-11-generic botocore/1.12.50

查看更多
我想做一个坏孩纸
6楼-- · 2019-04-18 01:18

This happens because of many reasons, one of it is wrong installation of aws

sudo pip install aws

Proper way of installing is (this should work if u do it without messing it up):

sudo pip install --upgrade --user awscli

Otherwise if you get any errors like: import awscli.clidriver

Then execute the command below to fix it:

sudo pip install awscli --force-reinstall --upgrade

and your awscli will be installed in (for Ubuntu 16)

/usr/local/bin/aws

Set the aws path:

export PATH=~/.local/bin:$PATH
查看更多
smile是对你的礼貌
7楼-- · 2019-04-18 01:20

I got into the same problem @ec2 ubuntu instance. What helped was to upgrade pip version: you get initially pip v 9.0.1. Upgrade it to current version (18.0 on day of writing this ) and you'll be fine

pip install --upgrade pip
查看更多
登录 后发表回答