首先介绍一下我的环境背景:
我用
在 ubuntu 机器上安装了 aws
pip install aws
我在终端中检查了以下命令
aws
给我输出:
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters] To see help text, you can run:
aws help aws <command> help aws <command> <subcommand> help aws: error: the following arguments are required: command
正如预期的那样。我还想知道需要注册哪个路径才能找到 aws。因此,我输入:
which aws
这给了我
/usr/bin/aws
然后我启动了一个 docker 容器,并在其中启动了一个 jupyter notebook 实例。我也将 /usr/bin 路径映射到 /usr/bin 。在 jupyter 笔记本中,我想确定我是否可以访问 /usr/bin/aws。我试过了:
!ls /usr/bin/aws
但什么也没找到。我仍然认为这很奇怪而且我不明白,因为我可以找到该文件夹的其余部分。正如预期的那样,在 jupyter 中输入“!aws”给了我一个“找不到命令”。
现在应该解决您的问题的部分来了:
在您的 jupyter 环境中安装 awscli,就像我一样,它可能与您成功运行 aws 命令的环境不同。在 jupyter 中运行:
!pip install awscli
我之前在终端中配置过aws。然而在 jupyter 中(在 docker 中),配置是空的。我附加到 docker 容器并按照官方教程运行“aws configure”。如果您不运行 docker 而是运行 anaconda 或任何虚拟环境,则需要进入此环境,然后 pip install aws 并在那里运行 aws configure。
一旦你这样做了,在你的 jupyter notebook 中输入“!aws”应该会给你预期的输出
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters] To see help text, you can run:
aws help aws <command> help aws <command> <subcommand> help aws: error: the following arguments are required: command
希望这会有所帮助。