首页 > 解决方案 > 找不到任何pip2,要使用pip。pip 需要安装

问题描述

我使用来自 venv 的 ansible 2.9 我在 AWS Linux
中使用 python 3.7 创建远程主机使用默认的 python 2.7,我无法升级它
我正在使用 boto3 并且需要安装它,但首先,我需要在远程安装 pip
我尝试调用它,但我不断得到:

fatal: [10.0.6.182]: FAILED! => changed=false
  invocation:
    module_args:
      chdir: null
      editable: false
      executable: null
      extra_args: null
      name:
      - pip
      requirements: null
      state: latest
      umask: null
      version: null
      virtualenv: null
      virtualenv_command: virtualenv
      virtualenv_python: null
      virtualenv_site_packages: false
  msg: Unable to find any of pip2, pip to use.  pip needs to be installed.

我正在使用 :

- name: Upgrade pip
  pip: name=pip state=latest
  tags:
    - packages

- name: Ensure botocore and boto3 modules are installed
  pip:
    name: [ "boto3", "botocore"]
    extra_args: "--user"

标签: python-3.xansible

解决方案


我认为您需要先使用 yum 安装 python2-pip,请尝试一下。如果您还有其他问题,请告诉我。

- name: install python2-pip
  yum:
    name: python2-pip
    state: present
- name: Upgrade pip
  pip: name=pip state=latest
  tags:
    - packages

- name: Ensure botocore and boto3 modules are installed
  pip:
    name: [ "boto3", "botocore"]
    extra_args: "--user"

推荐阅读