首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用python脚本部署到Ubuntu服务器,awsebcli失败

使用python脚本部署到Ubuntu服务器,awsebcli失败
EN

DevOps用户
提问于 2021-06-10 15:35:16
回答 1查看 169关注 0票数 1

就在昨天,在我们的AWS ElasticBeanstalk连续部署中一切都进行得很好,但是今天突然失败了,出现了以下错误:

代码语言:javascript
复制
$ 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

我们的初始部署脚本假设pythonVersion2.7和awsebcli安装。下面是脚本中的片段:

代码语言:javascript
复制
 - 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

但在收到此错误后,我决定切换到python3并安装pip3。下面是更新的脚本及其抛出的内容:

代码语言:javascript
复制
    - 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
代码语言:javascript
复制
$ 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

没有抛出明确的错误消息,所以我不明白为什么它会在代码1中存在。

EN

回答 1

DevOps用户

回答已采纳

发布于 2021-06-11 13:03:53

更新:

从json模块导入JSONDecoderError是一个有效的语法,仅从Python3.5开始,而在以前的版本中,它是ValueError类的子类。显然,最新版本的awsebcli 3.20.0应该使用python >= 3.5而不是python <= 2.7启动。

很明显什么都不适合我。虽然我使用了正式的aws、eb、cli安装脚本,并遵循了带有依赖项和验证可执行文件路径的指令。详细信息这里

最终的工作脚本如下所示:

代码语言:javascript
复制
$ 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
票数 1
EN
页面原文内容由DevOps提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://devops.stackexchange.com/questions/14140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档