【问题标题】:aws cli not working in Jupyter after successful pip install?成功安装 pip 后,aws cli 在 Jupyter 中不起作用?
【发布时间】:2018-09-28 23:06:56
【问题描述】:

我有一个运行 Python 3.7 的 Anaconda 环境

我有一个带有以下行的 Jupyter 笔记本:

!aws configure [....] #Can't display the rest of the code for privacy reasons

当我运行代码块时,我得到:

/bin/sh: aws: command not found

尽管已经跑了:

pip install awscli

成功了。

我该如何解决/调试这个问题?


我已经设法将其归结为 Jupyter 笔记本所看到的路径与 env 命令行中显示的路径不同的事实。我该如何解决?

【问题讨论】:

  • 在该环境中运行 jupyter notebook?

标签: python-3.x amazon-web-services pip aws-cli


【解决方案1】:

首先介绍一下我的环境背景:

我用

在 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

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2021-06-22
    • 2016-11-17
    • 2022-08-22
    • 2017-11-15
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 2023-03-30
    • 2016-05-20
    相关资源
    最近更新 更多