9

I am getting the below exception while trying to run any AWS command on my MacBook, for example:

Command

aws s3api create-bucket --bucket my_backup  --region us-west-2 --create- 
bucket-configuration LocationConstraint=us-west-1

Exception

Traceback (most recent call last):
File "/Users/avinash/.local/share/virtualenvs/pipend_shell_3- 
x8skfE25/bin/aws", line 7, in <module>
from aws.main import main
File "/Users/avinash/.local/share/virtualenvs/pipend_shell_3- 
x8skfE25/lib/python3.6/site-packages/aws/main.py", line 23
print '%(name)s: %(endpoint)s' % {
                             ^
SyntaxError: invalid syntax

I am using Python 3.6.5 and have installed aws:

pip install aws
3
  • 1
    The underscore is not allowed in the bucket name. Also, just to be sure, you're entering in that command all on one line? Commented Jul 10, 2018 at 20:19
  • @DavidFairbanks Thanks for pointing it out but result is same even after i replace underscore with hyphen Commented Jul 11, 2018 at 16:41
  • What OS are your running the AWS CLI on? If Windows, which install method (MSI or pip)? The syntax error is coming from the SDK. The print statement is for Python 2 and you are running Python 3. If you are on Windows try again using the latest Python 2.7 (or install from the MSI which includes the correct version of Python). For Windows the MSI method is what I recommend to install the AWS CLI. Commented Jul 12, 2018 at 0:05

2 Answers 2

29

I figured out the issue. I did pip install aws instead of pip install awscli.

We need to use the below command to install AWS CLI:

pip install awscli
Sign up to request clarification or add additional context in comments.

1 Comment

this is actually the correct answer. The 'aws' command you're using is not the aws cli
0
aws s3api create-bucket --bucket my_backup  --region us-west-2 --create-
bucket-configuration LocationConstraint=us-west-1

The regions for bucket creation and constraint are different. Both should be us-west-2 or us-west-1.

The "my-bucket" name could also be a restricted name and you might have to choose another name.

2 Comments

Thanks! But, this was just one of the command, actually all the aws commands were failing with same exception. though you are right, there are other syntax errors in this command, but aws actually tells us the exact issue in that case, like bucket name is not valid.
But not two lines?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.