0

Trying to create a Python application on ElasticBeanstalk using the CLI, after I select my platform version I get the following error:

Select a platform version.
1) Python 3.4
2) Python
3) Python 2.7
4) Python 3.4 (Preconfigured - Docker)
(default is 1): 1
ERROR: UnicodeDecodeError :: 'ascii' codec can't decode byte 0xe2 in position 891: ordinal not in range(128)

I found this: https://github.com/aws/aws-cli/issues/708 which makes me think maybe I pasted my AWS credentials with a newline attached. I'd like to re-enter the credentials but it seems they are cached somewhere (it asked me for them on the first install attempt but not any subsequence attempts). I do not see them in my environment vars and I have been deleting .elasticbeanstalk between attempts. Any ideas?

update: I deleted .aws/config so it allowed me to re-enter my credentials. Still get the same error when I try to run eb init

update2: gist of --debug output can be found here: https://gist.github.com/dshuhler/8d64849021c48bf1ba71

Dan S.
  • 1
  • 3

3 Answers3

3

tldr; My .gitignore had a hidden non-ascii character as I had copy pasted a Python specific .gitignore from a popular Github repository.


Steps I took to figure out the root cause

So, I couldn't find any answer that helped me solve this problem for me. Looks like, different people are seeing this error for different reasons.

I'm going to share the steps I took to figure out the cause for my problem. Make sure to run your command using --debug flag

$ eb init --debug

My output was something like this

2019-05-05 13:44:17,548 (INFO) eb : Traceback (most recent call last):
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/core/ebrun.py", line 62, in run_app
    app.run()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/cement/core/foundation.py", line 797, in run
    return_val = self.controller._dispatch()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/cement/core/controller.py", line 472, in _dispatch
    return func()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/cement/core/controller.py", line 478, in _dispatch
    return func()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/core/abstractcontroller.py", line 89, in default
    self.do_command()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/controllers/initialize.py", line 118, in do_command
    initializeops.setup(app_name, region_name, platform, dir_path=None, repository=repository, branch=branch)
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/operations/initializeops.py", line 57, in setup
    setup_ignore_file()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/operations/initializeops.py", line 92, in setup_ignore_file
    source_control.set_up_ignore_file()
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/site-packages/ebcli/objects/sourcecontrol.py", line 294, in set_up_ignore_file
    for line in f:
  File "/Users/mudassirali/.virtualenvs/rtp_dev/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1287: ordinal not in range(128)

I jumped into the source code, specifically this bit

for line in f:

I found out this is the part which was throwing the error

with open('.gitignore', 'r') as f:
    for line in f:
        if line.strip() == git_ignore[0]:
            return

Once I removed the .gitignore it worked like charm(and added it later without copy-paste)

Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
1

It could be that your Beanstalk runs the Python environment without LC_ALL defined. Setting LC_ALL=en_US.UTF-8 in my Beanstalk environment properties resolved this issue for me.

Some background on these locale environment variables is available at: Explain the effects of export LANG, LC_CTYPE, LC_ALL

HorsePunchKid
  • 848
  • 12
  • 17
0

your aws credentials are at ~/.aws/config

Tal
  • 7,827
  • 6
  • 38
  • 61
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/10847327) – 4dgaurav Jan 11 '16 at 07:27
  • @4dgaurav the person asked where are the credentials, and my answer fits his question. not sure why you think differently. – Tal Jan 11 '16 at 07:41
  • this might be a comment to OP's question, in case otherwise, if OP accepts your answer, I will delete my comment. – 4dgaurav Jan 11 '16 at 07:45
  • unfortunately this did not solve the problem. I updated the OP – Dan S. Jan 11 '16 at 13:46
  • @DanS. can you share the rest of your setup? run it with `--debug` and share the output in a gist. – Tal Jan 11 '16 at 15:55