<p>Update:</p>
<p>The import of JSONDecoderError from json module is a valid syntax only starting from Python 3.5, while in previous versions it was a subclass of ValueError class. Apparently the latest version of awsebcli 3.20.0 should launch with python &gt;= 3.5 instead of python &lt;= 2.7.</p>
<hr />
<p>Apparently nothing suggested worked for me. Though I used the official aws eb cli setup script and followed the instructions with dependencies and verifying paths to executables. Details <a href="https://github.com/aws/aws-elastic-beanstalk-cli/issues/75#issuecomment-859564327" rel="nofollow noreferrer">here</a>.</p>
<p>Final working script would look like this:</p>
<pre class="lang-bash prettyprint-override"><code>$ apt-get update -y
$ apt-get install -y build-essential zlib1g-dev libssl-dev libncurses-dev libffi-dev libsqlite3-dev libreadline-dev libbz2-dev
$ git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
$ ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer
$ echo 'export PATH=&quot;/root/.ebcli-virtual-env/executables:$PATH&quot;' &gt;&gt; ~/.bash_profile &amp;&amp; source ~/.bash_profile
$ echo 'export PATH=/root/.pyenv/versions/3.7.2/bin:$PATH' &gt;&gt; /root/.bash_profile &amp;&amp; source /root/.bash_profile
$ eb deploy production
</code></pre>

CC BY-SA 4.0
2021-06-11T13:03:53.083Z
2021-06-14T08:21:04.510Z
2021-06-14T08:21:04.510Z
magnump0
<p>Just yesterday everything worked fine on our AWS ElasticBeanstalk continuous deployment, but today suddenly fails with the following errors:</p>
<pre class="lang-bash prettyprint-override"><code>$ pip install awsebcli -q --upgrade
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
$ eb deploy production
Traceback (most recent call last):
  File &quot;/usr/local/bin/eb&quot;, line 5, in &lt;module&gt;
    from ebcli.core.ebcore import main
  File &quot;/usr/local/lib/python2.7/dist-packages/ebcli/core/ebcore.py&quot;, line 19, in &lt;module&gt;
    from ebcli.core import ebglobals, base, hooks
  File &quot;/usr/local/lib/python2.7/dist-packages/ebcli/core/hooks.py&quot;, line 20, in &lt;module&gt;
    from ebcli.core import fileoperations
  File &quot;/usr/local/lib/python2.7/dist-packages/ebcli/core/fileoperations.py&quot;, line 32, in &lt;module&gt;
    from json import load, JSONDecodeError
ImportError: cannot import name JSONDecodeError
Cleaning up file based variables
00:00
ERROR: Job failed: exit code 1
</code></pre>
<p>Our initial deploy script assumed python version 2.7 and installation of awsebcli. Here is the snippet from the script:</p>
<pre class="lang-yaml prettyprint-override"><code> - apt-get update -y
 - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
 - python get-pip.py
 - pip --version
 - pip install --upgrade pip setuptools
 - pip install awsebcli -q --upgrade
 - eb deploy production
</code></pre>
<p>But after receiving this error I decided to swap to python3 and install pip3 instead. Here is the updated script and what it throws:</p>
<pre class="lang-yaml prettyprint-override"><code>    - apt-get update -y
    - apt-get install -y python3-pip
    - update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
    - update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
    - update-alternatives --list python
    - python --version
    - pip3 --version
    - pip3 install awsebcli -q --upgrade
    - eb deploy production
</code></pre>
<pre class="lang-bash prettyprint-override"><code>$ update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.5
$ python --version
Python 3.5.3
$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
$ pip3 install awsebcli -q --upgrade
Command &quot;python setup.py egg_info&quot; failed with error code 1 in /tmp/pip-build-0a4fa4ab/awsebcli/
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
</code></pre>
<p>There is no explicit error message thrown, so I can't understand why exactly it exits with code 1. Can you please suggest anything?</p>

<gitlab><deployment><python><aws-cli><amazon-ebs>
Deploy to Ubuntu server with python script and awsebcli fails
magnump0
# Deploy to Ubuntu server with python script and awsebcli fails

(Asked by: username_0 on 2021-06-10)

Just yesterday everything worked fine on our AWS ElasticBeanstalk continuous deployment, but today suddenly fails with the following errors:
$ pip install awsebcli -q --upgrade
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
$ eb deploy production
Traceback (most recent call last):
  File "/usr/local/bin/eb", line 5, in 
    from ebcli.core.ebcore import main
  File "/usr/local/lib/python2.7/dist-packages/ebcli/core/ebcore.py", line 19, in 
    from ebcli.core import ebglobals, base, hooks
  File "/usr/local/lib/python2.7/dist-packages/ebcli/core/hooks.py", line 20, in 
    from ebcli.core import fileoperations
  File "/usr/local/lib/python2.7/dist-packages/ebcli/core/fileoperations.py", line 32, in 
    from json import load, JSONDecodeError
ImportError: cannot import name JSONDecodeError
Cleaning up file based variables
00:00
ERROR: Job failed: exit code 1

Our initial deploy script assumed python version 2.7 and installation of awsebcli. Here is the snippet from the script:
 - apt-get update -y
 - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
 - python get-pip.py
 - pip --version
 - pip install --upgrade pip setuptools
 - pip install awsebcli -q --upgrade
 - eb deploy production

But after receiving this error I decided to swap to python3 and install pip3 instead. Here is the updated script and what it throws:
    - apt-get update -y
    - apt-get install -y python3-pip
    - update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
    - update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
    - update-alternatives --list python
    - python --version
    - pip3 --version
    - pip3 install awsebcli -q --upgrade
    - eb deploy production

$ update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.5
$ python --version
Python 3.5.3
$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
$ pip3 install awsebcli -q --upgrade
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0a4fa4ab/awsebcli/
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1

There is no explicit error message thrown, so I can't understand why exactly it exits with code 1. Can you please suggest anything?

**Tags:** gitlab, deployment, python, aws-cli, amazon-ebs


---

## 1 answers

### Answer by username_0 on 2021-06-11. Score: 1 | Accepted answer

Update:
The import of JSONDecoderError from json module is a valid syntax only starting from Python 3.5, while in previous versions it was a subclass of ValueError class. Apparently the latest version of awsebcli 3.20.0 should launch with python >= 3.5 instead of python <= 2.7.

Apparently nothing suggested worked for me. Though I used the official aws eb cli setup script and followed the instructions with dependencies and verifying paths to executables. Details here.
Final working script would look like this:
$ apt-get update -y
$ apt-get install -y build-essential zlib1g-dev libssl-dev libncurses-dev libffi-dev libsqlite3-dev libreadline-dev libbz2-dev
$ git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
$ ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer
$ echo 'export PATH="/root/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile
$ echo 'export PATH=/root/.pyenv/versions/3.7.2/bin:$PATH' >> /root/.bash_profile && source /root/.bash_profile
$ eb deploy production


---

