awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.15k stars 769 forks source link

Support AWS CLI v2 #238

Open nathaniel-holder opened 4 years ago

nathaniel-holder commented 4 years ago

Hello,

When using AWS CLI v2, I get this error: 'Namespace' object has no attribute 'cli_binary_format' On Windows 10, Python 3.8.1

AWS CLI v2 reference: https://aws.amazon.com/blogs/developer/aws-cli-v2-is-now-generally-available/

Thanks!

xhiroga commented 4 years ago

I have same issue. After update aws-cli, aws-shell does not works.

Environment: os: macOS 10.15.3 awscli: aws-cli/2.0.0 Python/3.8.1 Darwin/19.3.0 botocore/2.0.0dev4 (installed by homebrew) aws-shell: 0.2.1 (installed by homebrew)

image

vitorbrandao commented 4 years ago

Same problem for me on macOS and with awscli installed via Homebrew:

$ aws --version
aws-cli/2.0.0 Python/3.8.2 Darwin/19.3.0 botocore/2.0.0dev7

If I use the pip installed module it works without issues:

$ python3 -m awscli --version
aws-cli/1.18.20 Python/3.7.7 Darwin/19.3.0 botocore/1.15.20
bwhaley commented 4 years ago

Is this project abandoned?

dushyantRathore commented 4 years ago

Even I am facing the same issue. Environment OS - macOS 10.15.4 AWS - aws-cli/2.0.8 Python/3.8.2 Darwin/19.4.0 botocore/2.0.0dev12

gauravdingolia commented 4 years ago

Do we have plans to maintain this? I was relying holistically on this until cli 2.0 happened 😐

yongkanghe commented 4 years ago

Any idea how to fix it? Run any command got this error.

$ aws-shell Creating doc index in the background. It will be a few minutes before all documentation is available. aws> configure

_'Namespace' object has no attribute 'cli_binaryformat'

xinbinhuang commented 4 years ago

Encountered the same problem. I am running WSL 18.04

I solved it by upgrading both the awscli and aws-shell together via pip

pip install -U awscli aws-shell

Hope this can be helpful for other people.

yongkanghe commented 4 years ago

Encountered the same problem. I am running WSL 18.04

I solved it by upgrading both the awscli and aws-shell together via pip

pip install -U awscli aws-shell

Hope this can be helpful for other people.

It fixed the issues. Thanks Xinbin!

nodakai commented 4 years ago

I solved it by upgrading both the awscli and aws-shell together via pip

That's perhaps because pip install awscli installs awscli v1 (1.18.69 as of today)

pujansrt commented 4 years ago

Encountered the same problem. I am running WSL 18.04

I solved it by upgrading both the awscli and aws-shell together via pip

pip install -U awscli aws-shell

Hope this can be helpful for other people.

Did not work for me.

tdfacer commented 4 years ago

I ran into this same issue, unfortunately, and as stated by someone else it appears as though installing both the awscli and the aws-shell together would not work because that would not currently install the awscli v2. I am on Arch Linux and I installed the awscli via these steps.

fopingn commented 4 years ago

Did not work also on Win10 Arch and awscli v2. Anyone who have the same problem

petrmvala commented 4 years ago

I am experiencing the same. By the look at this repository, all development was done in mid 2016 with some contributions in 2018, so I guess it is safe to assume that this project died (unless someone picks it up)

C-Kenny commented 4 years ago

Managed to get aws-shell running ok in a fresh virtual environment using:

aws-shell==0.2.1
awscli==1.18.91

Suspect this is related to AWS CLI version 2

vigneshbrb commented 4 years ago

I am also facing the same issue. I am unable to perform any actions. I always get 'Namespace' object has no attribute 'cli_binary_format'

I am using:

AWS CLI Version: aws-cli/2.0.19 Python/3.7.7 Windows/10 botocore/2.0.0dev23
kosmur commented 3 years ago

Encountered the same problem. I am running WSL 18.04

I solved it by upgrading both the awscli and aws-shell together via pip

pip install -U awscli aws-shell

Hope this can be helpful for other people.

This worked for me, thanks a lot.

psrivastava-rsc commented 3 years ago

Encountered the same problem. I am running WSL 18.04 I solved it by upgrading both the awscli and aws-shell together via pip

pip install -U awscli aws-shell

Hope this can be helpful for other people.

This worked for me, thanks a lot.

I have tried but it does not work. AWS CLi reverts back to 1.x version Could you check again if you are running now 2.0 in awscli.

aws --version

Truscle commented 3 years ago

Hi Guys,

After reading the information from this thread, I guess the root cause is awscli version conflict; aws-shell believes that you are using awscli version 1 that cli_binary_format is not supported; your system has both 2 versions and the command is executed with awscli version 2 which cli_binary_format could be mandatory.

The solution is cleaning up all version of awscli and aws-shell in your system, then reinstall them. That solved my issue.

Good luck, Kent

psrivastava-rsc commented 3 years ago

What are your installation commands for re-installing. Still Ihave no luck

chusiang commented 3 years ago

I have same problem on macOS v10.15.6.

[ chusiang@catalina ~ ] - 17:20
$ brew install awscli

[ chusiang@catalina ~ ] - 17:39
$ aws --version
aws-cli/2.0.33 Python/3.8.5 Darwin/19.5.0 botocore/2.0.0dev37

I will use the aws-shell command via Docker, I give up to fix this problem now. 😂

https://hub.docker.com/r/pahud/aws-shell

[ chusiang@catalina ~ ] - 17:49
$ docker run -it --rm -v $HOME/.aws:/root/.aws pahud/aws-shell
First run, creating autocomplete index...
Creating doc index in the background. It will be a few minutes before all documentation is available.
aws> s3 ls
2020-06-27 15:15:25 fooooooo
aws>

By the way, I also add one alias to disguise the aws-shell command.

$ echo "alias aws-shell='docker run -it --rm -v $HOME/.aws:/root/.aws pahud/aws-shell'" >> ~/.bash_aliases

Thanks for @pahud .

tomaszdudek7 commented 3 years ago

Is this project abandoned or not?

dserodio commented 3 years ago

Thanks @chusiang. Since I'm using aws-vault to store my Access Keys/Secret Keys instead of ~/.aws/credentials, I improved your alias by passing AWS_* environment variables to the container, and turned it into a wrapper script:

#!/bin/bash

function cleanup() {
    rm "${env_file}"
}

trap cleanup EXIT

env_file=$(mktemp)
env | grep ^AWS_ > "${env_file}"

docker run -it --rm -v $HOME/.aws:/root/.aws --env-file="${env_file}" pahud/aws-shell
rcalvachi commented 3 years ago

I fixed in Win10 by selecting in my PATH the AWS CLI v1.x. C:\Program Files\Amazon\AWSCLI

AWS CLI V2.x uses C:\Program Files\AWSCLIV2

So how do we get support for AWS CLI V2.x?

benoitm974 commented 3 years ago

you can fix with installing awscli@1 and changing your path:

brew install awscli@1 echo 'export PATH="/usr/local/opt/awscli@1/bin:$PATH"' >> ~/.zshrc

(change zshrc to whatever your shell is...)

Truscle commented 3 years ago

After reading the information from this thread, I guess the root cause is awscli version conflict; aws-shell believes that you are using awscli version 1 that cli_binary_format is not supported; your system has both 2 versions and the command is executed with awscli version 2 which cli_binary_format could be mandatory.

The solution is cleaning up all version of awscli and aws-shell in your system, then reinstall them. That solved my issue.

Hi Guys,

Please allow me to elaborate a bit what happened in macOS environment.

  1. Brew will install awscli v2 and a bunch of other components, including python 3, to /usr/local/Cellar. And create system links in /usr/local/bin etc.
  2. When using pip to install aws-shell, awscli (only v1 is available at the monment) etc., they will be installed in somewhere like $YOUR_PYTHON_HOME/3.8.5/lib/python3.8/site-packages.
  3. When executing aws --version, depends on your $PATH setting because your system have got 2 versions of awscli now, the system could use the version installed via brew. That's why you see version 2.x.x printed.
  4. When executing aws-shell, the aws-shell will load the awscli module installed within the same site-packages, which is awscli v1. That means aws-shell believes that he is interacting with version 1, thus he should not use cli_binary_format parameter.
  5. However, when you execute any aws command in aws-shell, e.g. s3 ls, aws-shell will call aws command to do the job. Now, please refer to #3 above. That means the aws-shell could be calling the awscli version 2 which requires the cli_binary_format parameter. That's why the 'Namespace' object has no attribute 'cli_binary_format' error occurred.

tips: execute sudo find / -name python to see where they are.

Gook luck, Kent

shanedroid commented 3 years ago

still hopeful that aws-shell isn't going away anytime soon and gets support for AWS CLI v2 ❤️

in the meantime based other examples given here I too have resorted to just using a docker container for aws-shell and have aws-vault handling auth by passing in an --env-file directly:

alias aws-shell-prod="docker run -it --rm -v $HOME/.aws:/root/.aws -v $PWD:/workspace --env-file <(aws-vault exec production -- env | grep ^AWS_) -w /workspace pahud/aws-shell"

thanks to @pahud @chusiang @dserodio

MikeLim7 commented 3 years ago

AWS have added auto-prompt mode to CLI v2, so aws-shell is not required unless you still need v1. See https://github.com/aws/aws-cli/issues/5664

imoisharma commented 3 years ago

Here is my solution and hopefully it will work. The issue in my case arises because of aws-shell in a different directory

Note- When we installed any package via HomeBrew, it put the package inside the .linuxbrew (hidden directory) which is separate from your $HOME dir.

See the image below. image

Step1: Find the aws-shell directory via which aws-shell (In my case it was inside this /home/linuxbrew/.linuxbrew/bin earlier) image

Step2: Once you find the directory, prefer to create a folder where you can put all the packages together. That can either be in /usr/bin or create your own ( In my case I put inside the /usr/local/bin)

image You can see I've got a bunch of other packages such as Ansible, terraform etc.

Step3: For Ubuntu users, find your .bashrc file and provide the path into it. Similar, other operating systems (such as windows, mac etc) can find their shell-script file and add the path.

image

(Additional Note- .bashrc is a shell script that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt. )

Don't forget to reload the .bashrc. To run refresh the .bashrc file, simply go to your $HOME yourterminal~$ . .bashrc (run dot-space-dotbashrc)

Voila it's working 👍🏻 image

Hope this helps :)

dangolbeeker commented 3 years ago

same issue windows keeps reverting cli back to v1

MikeLim7 commented 3 years ago

I am happy with v2's auto-prompt mode as described at https://github.com/aws/aws-cli/issues/5664

export AWS_CLI_AUTO_PROMPT=on
aws  # This will immediately enter auto-prompt mode
angryjenkins commented 3 years ago

tagging to follow this as well - enjoyed using aws-shell more than awscli, ... however work requires cli v2.

gimbo commented 3 years ago

@angryjenkins You don't need to comment in order to be informed about updates to an issue: just hit the subscribe button.

rahulitnetwork commented 3 years ago

I have same issue. After update aws-cli, aws-shell does not works.

Environment: os: macOS 10.15.3 awscli: aws-cli/2.0.0 Python/3.8.1 Darwin/19.3.0 botocore/2.0.0dev4 (installed by homebrew) aws-shell: 0.2.1 (installed by homebrew)

image

remove awscli v2 and use this command "pip install -U awscli aws-shell" it will work

randonia commented 2 years ago

Anyone landing here, I was able to fix it for myself (OSX Catalina 10.15.7) by force installing awscli@1 in with homebrew

# previously installed with just "brew install awscli"
❯ aws --version
aws-cli/2.2.18 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off
❯ aws-shell
aws> configure list
(failure output)
^D

❯ brew install awscli@1
Updating Homebrew...
(lots of output)
# for some reason this is the same
❯ aws --version
aws-cli/2.2.18 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off
❯ aws-shell
aws> configure list
(successful output)

Might not be ideal, but it at least works today

imoisharma commented 2 years ago

Can we close this issue now @nathaniel-holder? If it resolved the issue? cc @awslabs

nathaniel-holder commented 2 years ago

Can we close this issue now @nathaniel-holder? If it resolved the issue? cc @awslabs

Fine with me @imoisharma, if it's true that CLI v2 supports aws-shell features. I don't have the bandwidth to verify that right now.

jcasadella commented 2 years ago

Can we close this issue now @nathaniel-holder? If it resolved the issue? cc @awslabs

Fine with me @imoisharma, if it's true that CLI v2 supports aws-shell features. I don't have the bandwidth to verify that right now.

Hi there! I've executed the steps proposed by @randonia but for me, the issue persists 😞

Here are my steps (running on OSX Big Sur 11.5):

# previously installed with just "brew install awscli
> aws --version
aws-cli/2.2.28 Python/3.9.6 Darwin/20.6.0 source/x86_64 prompt/off
> aws-shell
aws> s3 ls
'Namespace' object has no attribute 'cli_binary_format'
^D

> brew install awscli@1
...
==> Summary
🍺  /usr/local/Cellar/awscli@1/1.20.10: 11,559 files, 79.8MB
# still the same aws version as @randonia pointed out
> aws --version
aws-cli/2.2.28 Python/3.9.6 Darwin/20.6.0 source/x86_64 prompt/off
# But when doing an s3 ls the shell crashes
> aws-shell
aws> s3 ls
'Namespace' object has no attribute 'cli_binary_format'

# With the aws command, the `s3 ls` works correctly:
> aws s3 ls
(list of buckets...)
psrivastava-rsc commented 2 years ago

This issue persists

kyleknap commented 2 years ago

@nathaniel-holder The AWS CLI v2 makes AWS Shell features available through its auto-prompt feature. We have the relationship between the AWS Shell and auto-prompt mode detailed here: https://github.com/awslabs/aws-shell/issues/253. The auto-prompt functionality is fairly well illustrated in this issue: https://github.com/aws/aws-cli/issues/5664 and in a re:Invent talk I presented that covered it.

While auto-prompt mode has some features that the AWS Shell does not (e.g. output panel), the most notable gap in functionality in auto-prompt mode when compared to the AWS Shell is that it does not offer a persistent shell for running CLI commands. We have a GitHub features open tracking the addition of an explicit shell mode (e.g., aws shell command) directly into v2: https://github.com/aws/aws-cli/issues/5665

In terms of this GitHub issue, I'd prefer to close it in favor of the issue tracking the addition of an explicit shell mode built into the AWS CLI v2 for reasons similar to why we launch auto-prompt mode directly in v2: https://github.com/awslabs/aws-shell/issues/253.

Thoughts? For those tracking this issue:

  1. If you want a shell mode even with auto-prompt mode in the AWS CLI v2, add the 👍 reaction to the v2 tracking issue for an explicit shell mode: https://github.com/aws/aws-cli/issues/5665.
  2. If you do not want this issue to be closed in favor of https://github.com/aws/aws-cli/issues/5665, please comment why.
merps commented 2 years ago

FWIW - new mbp 13" (macOS Big Sur 11.5.2) and functioning as per @randonia suggestion:

# from previous before suggested, depreciated, fix:
➜  /Users aws --version 
aws-cli/2.2.29 Python/3.9.6 Darwin/20.6.0 source/x86_64 prompt/off

# Installation of previous build:
➜  ~ brew install awscli@1
Updating Homebrew...
Warning: awscli@1 1.20.10 is already installed and up-to-date.
To reinstall 1.20.10, run:
  brew reinstall awscli@1

# export as per homebrew directions for precedent processing:
➜  ~ echo 'export PATH="/usr/local/opt/awscli@1/bin:$PATH"' >> ~/.zshrc

# source environment to refresh current shell:
➜  ~ source ~/.zshrc

# validation of environment reload:
➜  ~ env | grep PATH
PATH=/usr/local/opt/awscli@1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin 

# validation of path precedents:
➜  ~ aws --version
aws-cli/1.20.10 Python/3.9.6 Darwin/20.6.0 botocore/1.21.10

# Testing of aws-shell:
➜  ~ aws-shell 
aws> ec2 describe-vpcs
{
    "Vpcs": [
        {
            "CidrBlock": "10.0.0.0/16",
            "DhcpOptionsId": "dopt-xxxxxx",
            "State": "available",
            "VpcId": "vpc-xxxxxxxxxxxx",
            "OwnerId": "xxxxxxxxxxxxxx",
            "InstanceTenancy": "default",
            "CidrBlockAssociationSet": [
                {
                    "AssociationId": "vpc-cidr-assoc-xxxxxxxxxxxx",
                    "CidrBlock": "10.0.0.0/16",
                    "CidrBlockState": {
                        "State": "associated"
                    }
                }
            ],

removed id's due to internal AWS account usage

Hopefully this help some-else bridge the gap until [v2][auto-prompt] Shell mode for AWS CLI auto-prompt

be well all...

cjhodges77 commented 2 years ago

Any update on this? I'm still getting the error with version 2

DrDiman commented 2 years ago

u can use cli v2 as aws --cli-auto-prompt

or u can set cli_auto_prompt = on in the aws cli config and aws command will prompt u everything)

qzeeshan commented 2 years ago

Yes, I can confirm that it seems like they've embedded shell into cli from v2.0.

It was giving me issues as well, but when I ran auto_prompt ON, cli is now working as shell and that error ['Namespace' object has no attribute 'cli_binary_format'] is gone...

github_comment_aws_cli_v2 2

Thanks @DrDiman