aws-elastic-beanstalk-cli-setup icon indicating copy to clipboard operation
aws-elastic-beanstalk-cli-setup copied to clipboard

SyntaxError: invalid syntax On Running eb command.

Open PranuPranav97 opened this issue 2 years ago • 4 comments

1. Please specify the following:

  • OS: [Ubuntu 20.04]: ___

  • Shell (Bash): ____

  • [x] I have reviewed the troubleshooting tips described here and they do not solve my problem

2. Description I installed EB cli from this link using commands https://github.com/aws/aws-elastic-beanstalk-cli-setup Whenever I run eb command it shows the error: `Error processing line 1 of /home/$user/.ebcli-virtual-env/lib/python3.8/site-packages/distutils-precedence.pth:

Traceback (most recent call last): File "/usr/lib/python2.7/site.py", line 158, in addpackage exec line File "", line 1, in File "/home/$user/.ebcli-virtual-env/lib/python3.8/site-packages/distutils_hack/init.py", line 194 f'spec_for{name}', ^ SyntaxError: invalid syntax `

PranuPranav97 avatar Oct 04 '22 10:10 PranuPranav97

Same issue here

jadbox avatar Oct 15 '22 00:10 jadbox

I think there might be a missing instruction in the README to activate the virtualenv create before using eb.

When I'd run

eb --version

I would get the following output

Error processing line 1 of /Users/alejandrofranco/.ebcli-virtual-env/lib/python3.10/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
    File "/Users/alejandrofranco/.ebcli-virtual-env/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 194
      f'spec_for_{name}',
                       ^
  SyntaxError: invalid syntax

Remainder of file ignored
EB CLI 3.20.3 (Python 3.10.)

It seems the eb executable needs to be called with the virtualenv that was created (usually ~/.ebcli-virtual-env) activated. To learn how to use virtualenv and activate a specific environment, I watched Corey Schafer tutorial

Essentially, activate the environment

source ~/.ebcli-virtual-env/bin/activate

Then running

eb --version

Doesn't give the error and I simply see the following output

EB CLI 3.20.3 (Python 3.10.)

To deactivate the virtualenv run

deactivate

alejo4373 avatar Oct 23 '22 16:10 alejo4373

same problem here, bash version 5.1.16(1)-release (x86_64-apple-darwin21.1.0) on MacOS 12.2 (21D49)

$ eb --version
Error processing line 1 of /Users/home/.ebcli-virtual-env/lib/python3.10/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
    File "/Users/home/.ebcli-virtual-env/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 194
      f'spec_for_{name}',
                       ^
  SyntaxError: invalid syntax

Remainder of file ignored
EB CLI 3.20.3 (Python 3.10.)

slavking avatar Feb 27 '23 19:02 slavking

I had the same issue and resolved with a combination of activating the virtual environment as recommended by @alejo4373 followed by issuing a command in the virtual environment to install an older version of urllib3. I found a Stack overflow article regarding similar errors with AWS Lambda stating that botocore does not support urllib3 v2+ (https://stackoverflow.com/questions/76414514/cannot-import-name-default-ciphers-from-urllib3-util-ssl-on-aws-lambda-us)

$ source ~/.ebcli-virtual-env/bin/activate
$ pip install --force-reinstall -v "urllib3==1.26.16"
$ eb --version
EB CLI 3.20.6 (Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0])

pmccaughtry avatar Jun 14 '23 00:06 pmccaughtry