简体   繁体   English

当 EB 环境为 python 3.6 时,使用 python 2.7 安装要求时出现 AWS 错误

[英]AWS errors when installing requirements with python 2.7 when EB environment is python 3.6

How do I get the aWS EB instance to use the python 3 version that is already installed on the instance?如何让 AWS EB 实例使用实例上已安装的 python 3 版本? I can't get a new environment running with Python 3.6 running Django 2.1+.我无法获得运行 Python 3.6 运行 Django 2.1+ 的新环境。

Local (not in virtual env):本地(不在虚拟环境中):

which python -> /usr/local/bin/python
python -V -> Python 2.7.15
which python3 -> /usr/local/bin/python3
python3 -V -> Python 3.6.5
which pip -> /usr/local/bin/pip
pip -V -> pip 18.0 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)`
which pip3 -> /usr/local/bin/pip3
pip3 -V -> pip 18.0 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Local in virtualenv mstFirst :本地在 virtualenv mstFirst

which python -> /Users/me/.virtualenvs/mstFirst/bin/python
which python3 -> /Users/me/.virtualenvs/mstFirst/bin/python
python -V -> Python 3.6.5
python3 -V -> Python 3.6.5
which pip -> /Users/me/.virtualenvs/mstFirst/bin/pip
which pip3 -> /Users/me/.virtualenvs/mstFirst/bin/pip3
pip -V -> pip 18.0 from /Users/me/.virtualenvs/mstFirst/lib/python3.6/site-packages/pip (python 3.6)
pip3 -V -> pip 18.0 from /Users/me/.virtualenvs/mstFirst/lib/python3.6/site-packages/pip (python 3.6)
aws --version -> aws-cli/1.16.9 Python/3.6.5 Darwin/17.7.0 botocore/1.11.9
eb --version -> EB CLI 3.14.4 (Python 3.6.5)
eb -list -> * mst-p3
eb -config ->
  ApplicationName: mst
  DateUpdated: 2018-09-07 02:15:51+00:00
  EnvironmentName: mst-p3
  PlatformArn: arn:aws:elasticbeanstalk:us-east-1::platform/Python 3.6 running on 64bit Amazon Linux/2.7.3
  settings: …

Files :文件

".elasticbeanstalk/config.yml" “.elasticbeanstalk/config.yml”

branch-defaults:
  master:
    environment: mst-p3
environment-defaults:
  mst-p3: …
global:
  application_name: mst
  default_platform: 64bit Amazon Linux 2018.03 v2.7.3 running Python 3.6
  default_region: us-east-1
  workspace_type: Application
…

".ebextensions/01_packages.config" “.ebextensions/01_packages.config”

packages:
  yum:
    git: []
    python36: []
    python36-devel: []
    postgresql93: []
    postgresql93-devel: []
    mod24_ssl : []

commands:
  pip_upgrade:
    command: /opt/python/run/venv/bin/pip install --upgrade pip
    ignoreErrors: false

Error when trying eb deploy , which points to wrong python version (2.7) while trying to run pip install -r requirements.py :尝试eb deploy时出错,它在尝试运行pip install -r requirements.py时指向错误的 python 版本 (2.7):

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-jt3_s4in/slugger/
2018-09-07 03:28:35,315 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
Traceback (most recent call last):
  File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
    install_dependencies()
  File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
    check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
  File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

Remote Instance ssh ( eb ssh ) :远程实例 ssh ( eb ssh )

pyhthon -V -> Python 2.7.14
pyhthon3 -V -> Python 3.6.5

Things I've tried:我尝试过的事情:

Using eb init definitely works: 使用eb init绝对有效:

eb init -p "64bit Amazon Linux 2017.09 v2.7.3 running Python 3.6" ...

Then just remove all the python stuff from your .ebextension files. 然后,只需从.ebextension文件中删除所有python内容.ebextension

For the yum section , all I use is: 对于yum section ,我所使用的是:

packages:
  yum:
    postgresql94-devel: []

There should be no need to upgrade pip. 应该没有必要升级点数。

Your problem is caused by the wrong version of pip (Python 3.x pip) in the Python 2.7 installation. 您的问题是由Python 2.7安装中的pip版本错误(Python 3.x pip)引起的。

The AWS tools are written for Python 2.7 AWS工具是为Python 2.7编写的

I am also not sure if aws cli or eb has been completely tested with pip 18. 我也不确定aws cli或eb是否已通过pip 18进行了完整测试。

Uninstall pip from the Python 2 directory. 从Python 2目录中卸载pip。 Uninstall eb 卸载eb

Reinstall. 重新安装。

I recommend installing the AWS CLI first even if you are not using it. 我建议即使不使用AWS CLI,也要先安装它。 This will ensure that your Python environment is setup correct for AWS tools. 这将确保您的Python环境对于AWS工具而言设置正确。

You did not specify the OS, so I cannot give you OS specific uninstall / install directions. 您没有指定操作系统,因此我无法为您提供特定于操作系统的卸载/安装说明。

Try:尝试:

  • backing up and delete.elasticbeanstalk/config.yml备份和删除.elasticbeanstalk/config.yml
  • run: eb init You can then select python version 3.6 within eb init运行:eb init 然后你可以在 eb init 中运行 select python 版本 3.6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python 2.7环境中安装pycairo时出现IOError - IOError when installing pycairo on Python 2.7 environment 为Python 2.7安装MySQL-python模块时出错 - Errors When Installing MySQL-python module for Python 2.7 当我已经在使用Anaconda Python 2.7时安装python 3.6 - Installing python 3.6 , when I am already using Anaconda Python 2.7 在Mac上并排安装Python 2.7和3.6 - Installing Python 2.7 and 3.6 Side by Side on Mac 如何在conda环境中将python 2.7替换为3.6? - How to replace python 2.7 to 3.6 in a conda environment? 安装GDAL for Python 3.6时的ImportError - ImportError when Installing GDAL for Python 3.6 当我已经安装了python 3.6时,如何在运行python(和pipenv)2.7的pycharm中设置虚拟环境? - How do I set up a virtual environment in pycharm which runs python (and pipenv) 2.7 when I already have python 3.6 installed? 安装 python 2.7 和 3.6 时,将 python 3.6 venv 用于 python 3 模块 - Using a python 3.6 venv for python 3 modules when python 2.7 and 3.6 are both installed 为Python 2.7安装NumPy时出现ImportError - ImportError when installing NumPy for Python 2.7 从 2.7 升级到 3.6 时出现 python requests.post 错误 - python requests.post error when upgrade from 2.7 to 3.6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM