Alex Kinman
Alex Kinman

Reputation: 2615

aws cli not working in Jupyter after successful pip install?

I have an Anaconda environment running with Python 3.7

I have a Jupyter notebook with the following line:

!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. How do I fix that?

Upvotes: 3

Views: 4738

Answers (1)

rob
rob

Reputation: 329

First a bit of background on my environment:

I installed aws on a ubuntu machine with

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. Therefore, I typed:

which aws

Which gave me

/usr/bin/aws

I then started a docker container where I started a jupyter notebook instance. I had mapped the /usr/bin path to /usr/bin as well. Within the jupyter notebook I wanted to be sure whether I had access to /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".

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. To do it run in jupyter:

!pip install awscli

I had configured aws in the terminal before. Yet within jupyter (within docker), the config was empty. I attached to the docker container and ran "aws configure", following the official tutorial for that. 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.

Once you did this, typing "!aws" in your jupyter notebook should give you the expected output of

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.

Upvotes: 4

Related Questions