简体   繁体   English

成功安装 pip 后,aws cli 在 Jupyter 中不起作用?

[英]aws cli not working in Jupyter after successful pip install?

I have an Anaconda environment running with Python 3.7我有一个运行 Python 3.7 的 Anaconda 环境

I have a Jupyter notebook with the following line:我有一个带有以下行的 Jupyter 笔记本:

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

When I run the code chunk, I get:当我运行代码块时,我得到:

/bin/sh: aws: command not found

Despite having run:尽管已经运行:

pip install awscli

successfully.成功地。

How can I solve/debug this?我该如何解决/调试这个问题?


I've managed to pin it down to the fact that the path that the Jupyter notebook is seeing and the path that is displayed in the env command line are not the same.我设法将其归结为 Jupyter 笔记本看到的路径与 env 命令行中显示的路径不同的事实。 How do I fix that?我该如何解决?

First a bit of background on my environment:首先介绍一下我的环境:

I installed aws on a ubuntu machine with我在 ubuntu 机器上安装了 aws

pip install aws

I checked that the following command in the terminal我检查了终端中的以下命令

aws

gave me the output:给了我输出:

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

as expected.正如预期的那样。 I also wanted to know which path would need to be registered to find aws.我还想知道需要注册哪个路径才能找到 aws。 Therefore, I typed:因此,我输入:

which aws

Which gave me这给了我

/usr/bin/aws

I then started a docker container where I started a jupyter notebook instance.然后我启动了一个 docker 容器,在那里我启动了一个 jupyter notebook 实例。 I had mapped the /usr/bin path to /usr/bin as well.我也将 /usr/bin 路径映射到 /usr/bin 。 Within the jupyter notebook I wanted to be sure whether I had access to /usr/bin/aws.在 jupyter notebook 中,我想确定我是否可以访问 /usr/bin/aws。 I tried:我试过:

!ls /usr/bin/aws

but found nothing.但一无所获。 Which I still think is weird and I don't understand, because the rest of that folder I can find.我仍然认为这很奇怪,我不明白,因为我可以找到该文件夹​​的其余部分。 As expected then, typing "!aws" in jupyter gave me a "command not found".正如预期的那样,在 jupyter 中输入“!aws”给了我一个“找不到命令”。

Now here comes the part that should solve your problem as well:现在来了也应该解决您的问题的部分:

Install awscli in your jupyter environment, which likely, just like for me, is not the same as the one where you ran your aws command successfully.在您的 jupyter 环境中安装 awscli,就像我一样,这可能与您成功运行 aws 命令的环境不同。 To do it run in jupyter:要做到这一点,请在 jupyter 中运行:

!pip install awscli

I had configured aws in the terminal before.我之前在终端里配置过aws。 Yet within jupyter (within docker), the config was empty.然而在 jupyter 中(在 docker 中),配置是空的。 I attached to the docker container and ran "aws configure", following the official tutorial for that.我连接到 docker 容器并按照官方教程运行“aws configure”。 If you don't run docker but instead anaconda or any virtual environment, you would need to enter this environment and then pip install aws and run aws configure there.如果您不运行 docker 而是运行 anaconda 或任何虚拟环境,则需要进入此环境,然后 pip install aws 并在那里运行 aws configure。

Once you did this, typing "!aws" in your jupyter notebook should give you the expected output of一旦你这样做了,在你的 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

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM