aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Can't install / configure aws cli

Open AndreiMotinga opened this issue 10 years ago • 16 comments

after installation when I run aws configure I get

Traceback (most recent call last):
  File "/usr/local/bin/aws", line 27, in <module>
    sys.exit(main())
  File "/usr/local/bin/aws", line 23, in main
    return awscli.clidriver.main()
  File "/usr/local/lib/python2.7/site-packages/awscli/clidriver.py", line 49, in main
    driver = create_clidriver()
  File "/usr/local/lib/python2.7/site-packages/awscli/clidriver.py", line 57, in create_clidriver
    load_plugins(session.full_config.get('plugins', {}),
  File "/usr/local/lib/python2.7/site-packages/botocore/session.py", line 361, in full_config
    self._config = botocore.config.load_config(config_file)
  File "/usr/local/lib/python2.7/site-packages/botocore/config.py", line 106, in load_config
    parsed = raw_config_parse(config_filename)
  File "/usr/

What steps can I take to fix it?

AndreiMotinga avatar Feb 08 '16 16:02 AndreiMotinga

The traceback looks incomplete. Could you include the entire stack trace? That would help troubleshoot what's going on.

Without more information, my initial guess would be a syntax error in the AWS config file. Can you confirm:

  • Does the ~/.aws/credentials file exist? If so, does it have contents?
  • Does the ~/.aws/config file exist? If so, does it have contents?
  • If you don't have either of those files, is the env var AWS_CONFIG_FILE set? If that's pointing to an existing file, does it have contents

jamesls avatar Feb 13 '16 00:02 jamesls

none of those files exist. since installation didn't succeed I didn't try to make them manually. If I'm correct I was supposed to be able to run aws configure to set all those up. the full stack trace when I run aws is

➜  ~  aws
Traceback (most recent call last):
  File "/usr/local/bin/aws", line 27, in <module>
    sys.exit(main())
  File "/usr/local/bin/aws", line 23, in main
    return awscli.clidriver.main()
  File "/usr/local/lib/python2.7/site-packages/awscli/clidriver.py", line 49, in main
    driver = create_clidriver()
  File "/usr/local/lib/python2.7/site-packages/awscli/clidriver.py", line 57, in create_clidriver
    load_plugins(session.full_config.get('plugins', {}),
  File "/usr/local/lib/python2.7/site-packages/botocore/session.py", line 361, in full_config
    self._config = botocore.config.load_config(config_file)
  File "/usr/local/lib/python2.7/site-packages/botocore/config.py", line 106, in load_config
    parsed = raw_config_parse(config_filename)
  File "/usr/local/lib/python2.7/site-packages/botocore/config.py", line 132, in raw_config_parse
    raise botocore.exceptions.ConfigParseError(path=path)
botocore.exceptions.ConfigParseError: Unable to parse config file: /Users/andrei/.aws/config
➜  ~

I've tried installing and resinstall with force, and update.. no changes.

AndreiMotinga avatar Feb 13 '16 01:02 AndreiMotinga

Interesting. It looks like it's failing to parse ~/.aws/config. Can you try putting in fake values? Here's the exact steps I tried, which works for me:

$ cat > ~/.aws/config
[default]
region=us-west-2
aws_access_key_id=foo
aws_secret_access_key=bar

$ aws configure
AWS Access Key ID [****************foo]:
AWS Secret Access Key [****************bar]:
Default region name [us-west-2]:
Default output format [None]:
$

Do those steps work for you? If so, you should now be able to add your real credential values by rerunning aws configure. I'm not sure how you got into this state. I confirmed that creating an empty ~/.aws/config file works as expected:

[ec2-user@ip-10-0-0-87 ~]$ rm ~/.aws/config
[ec2-user@ip-10-0-0-87 ~]$ touch ~/.aws/config
[ec2-user@ip-10-0-0-87 ~]$ aws configure
AWS Access Key ID [None]: foo
AWS Secret Access Key [None]: bar
Default region name [None]: us-west-2
Default output format [None]:

jamesls avatar Feb 15 '16 22:02 jamesls

Yes, these steps have helped me. It works now.

Thank you @jamesls

AndreiMotinga avatar Feb 17 '16 18:02 AndreiMotinga

Glad to hear it's working. Closing out issue.

jamesls avatar Feb 25 '16 18:02 jamesls

I had the same problem and then found out that having a line with only one space causes this error to occur.

cfzlp avatar Aug 15 '16 11:08 cfzlp

I am currently having this issue - I wan't able to follow the steps as I do not have an aws config file. Do you know how this could work?

fabrikate avatar Oct 14 '16 22:10 fabrikate

For me, I was missing an equals sign = between aws_access_key_id and its value in the credentials file. I ended up just renaming credentials file and running aws configure.

kjprice avatar Oct 19 '16 12:10 kjprice

@jamesls awesome dude.Your solution is working like a dream!

perasr avatar Apr 22 '17 18:04 perasr

I had this issue as well and the only way to get them working was to manually deleting the files config and credentials from C:\Users\yourusername\.aws and run the command aws configure to regenerate them.

MoisesCardenas avatar Feb 13 '18 00:02 MoisesCardenas

The problem is that the configure file cannot be parsed. Re-create the configure file and make sure that is formatted correctly.

xtreamgit avatar Apr 05 '18 00:04 xtreamgit

I came across this problem recently after writing a script that modified .aws/credentials (to automate some of my 2FA steps).

It looks like if the encoding is "UTF-8-BOM", botocore raises a ConfigParseException. If I change the same config file to "UTF-8", for example using Notepad++, then ini file is parsed correctly.

MetalMichael avatar Jun 28 '18 21:06 MetalMichael

Traceback (most recent call last): File "/usr/local/bin/aws", line 27, in sys.exit(main()) File "/usr/local/bin/aws", line 23, in main return awscli.clidriver.main() File "/usr/local/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 59, in main rc = driver.main() File "/usr/local/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 197, in main parsed_args, remaining = parser.parse_known_args(args) File "/usr/local/aws/lib/python2.7/site-packages/awscli/argparser.py", line 91, in parse_known_args parsed, remaining = super(CLIArgParser, self).parse_known_args(args, namespace) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1733, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1774, in _parse_known_args option_tuple = self._parse_optional(arg_string) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 2082, in _parse_optional option_tuples = self._get_option_tuples(arg_string) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 2125, in _get_option_tuples if option_string.startswith(option_prefix): UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 10: ordinal not in range(128)

This is the error i am getting.Unable to fix

suresh-thatikonda avatar Jul 27 '18 00:07 suresh-thatikonda

Issue in my case was that i was adding manual entries, and i had empty lines between entries. Removing those extra lines fixed my issue. Or just use aws configure --profile name_of_profile command and it should work.

ziaulrehman40 avatar Apr 24 '19 08:04 ziaulrehman40

I had this issue as well and the only way to get them working was to manually deleting the files config and credentials from C:\Users\yourusername\.aws and run the command aws configure to regenerate them.

Even I had the same issue and got resolved on following the above steps..

dkonnurBNT avatar Jan 28 '20 10:01 dkonnurBNT

I encountered this issue inside a Windows container (Windows Server, Docker Enterprise Edition, i.e. not the Hyper-V based "Docker Desktop", but real containers using process isolation). I presume the issue is similar outside containers as well.

I was piping the config and credential files from snail strings (@"string"@) to out-file in Powershell as part of an entrypoint script and encountering the same unable to parse file .aws/config error from aws-cli. I checked the format of these files on my linux workstation, and rather than being utf-8, they are actually ascii. Once I set out-file to use -encoding ascii everything worked fine, without having to invoke aws configure, allowing me to continue to do everything programmatically inside the container. Hopefully this helps someone else who lands here as a result of the googles.

DJFormica avatar Mar 03 '21 00:03 DJFormica