aws / aws-elastic-beanstalk-cli-setup

Simplified EB CLI installation mechanism.
Apache License 2.0
519 stars 227 forks source link

SyntaxError: invalid syntax On Running eb command. #138

Open PranuPranav97 opened 2 years ago

PranuPranav97 commented 2 years ago

1. Please specify the following:

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'specfor{name}', ^ SyntaxError: invalid syntax `

jadbox commented 2 years ago

Same issue here

alejo4373 commented 2 years ago

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
slavking commented 1 year ago

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.)
pmccaughtry commented 1 year ago

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])