LoginSignup
1
1

More than 1 year has passed since last update.

git cloneしたら"ModuleNotFoundError: No module named 'awscli'"が発生した

Posted at

事象

EC2でCodeCommitに対してgit cloneしたら、エラーになってしまいました。

[ssm-user@ip-99-99-99-99 ~]$ git clone https://git-codecommit.ap-northeast-1.amazonaws.com/xxxxxx
Cloning into 'xxxxxxx'...
Traceback (most recent call last):
  File "/usr/bin/aws", line 19, in <module>
    import awscli.clidriver
ModuleNotFoundError: No module named 'awscli'
Username for 'https://git-codecommit.ap-northeast-1.amazonaws.com/xxxxxx': ^[^C
  • git cloneなのになぜかawscliがないというエラー
  • エラーの後になぜかUsernameを尋ねられる

前提

  • EC2(Linux2)
  • SSMでログイン
  • 認証情報ヘルパーを以前にこのEC2で設定している
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

参考:https://docs.aws.amazon.com/ja_jp/codecommit/latest/userguide/setting-up-https-unixes.html#setting-up-https-unixes-credential-helper

解決方法

awscliをアンインストール→再度インストールしたら解決しました。

[ssm-user@ip-99-99-99-99 ~]$ sudo yum remove awscli
[ssm-user@ip-99-99-99-99 ~]$ sudo yum install aws-cli

参考:https://docs.aws.amazon.com/ja_jp/cli/v1/userguide/install-linux-al2017.html

感想

git cloneするときに、裏で認証情報ヘルパーを使って認証が走っています。
認証情報ヘルパーではaws codecommitコマンドを使っているから、awscliが壊れていると今回のようなエラーが出たのだろうと推測します。
何にせよ、直ってよかった。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1