LoginSignup
37

More than 3 years have passed since last update.

AWS CLI の パス を通す

Posted at

はじめに

mac, awscli command not found とかがキーワード。
本記事の前提は pip3 で awscli のインストールをしたという前提です。

公式はこちら
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-macos.html#awscli-install-osx-path

似ている記事はこのあたり。

https://qiita.com/mokuo/items/0484feefbaddb70a9b06
https://qiita.com/yuyj109/items/3163a84480da4c8f402c
https://blog.sioyaki.com/entry/2018/09/20/124123

解決する問題

aws --version がせめて表示されるようにする。
実行ファイルにパスを通していないとこんな感じ。

$ cd ~
$ aws --version
-bash: aws: command not found

なるほど。

$ pip3 list | grep aws
aws cli   1.16.157

はい。インストールされていますね。
この時点で何も出力されていない方は、こちらへどうぞ。
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-macos.html#awscli-install-osx-pip

pip3 はどこに何を入れたのか確認する

$ pip3 show awscli
Name: awscli
Version: 1.16.157
Summary: Universal Command Line Environment for AWS.
Home-page: http://aws.amazon.com/cli/
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /Users/使っている人のユーザ名/Library/Python/3.7/lib/python/site-packages
Requires: PyYAML, docutils, rsa, botocore, colorama, s3transfer
Required-by: 

なるほど。 Location に何かありそうだなと判断できそうです

ここで注意点!

.bash_profile に、

export /Users/umekage/Library/Python/3.7/lib/python/site-packages:$PATH 

ってやってもこれはダメ。実行ファイルはここにはないのです!

実行ファイルはどこか確認する

ちゃんと、 /bin を捕まえておきましょう

$ pip3 show awscli -f | grep /bin
  ../../../bin/aws 
  ../../../bin/aws.cmd
  ../../../bin/aws_bash_completer
  ../../../bin/aws_completer
  ../../../bin/aws_zsh_completer.sh

ということで、ディレクトリを上がればなんとかなりそうと分かります
この相対パスは Location で見たところからの相対パス。

結論

.bash_profile は以下のとおり記載できます

export PATH=/Users/使っている人のユーザ名/Library/Python/3.7/bin:$PATH

意気揚々と実行しましょう!

$ aws --version
aws-cli/1.16.157 Python/3.7.3 Darwin/18.5.0 botocore/1.12.147

完璧ですね。これで世界を革命する力を得たといっても過言ではありません!!!!

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
37