AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1030419
Accepted
JeremyCanfield
JeremyCanfield
Asked: 2020-08-18 02:13:29 +0800 CST2020-08-18 02:13:29 +0800 CST 2020-08-18 02:13:29 +0800 CST

Ansible - pip3 安装失败

  • 772

我正在尝试在 CentOS 7 上安装 Ansible,并将 Ansible 配置为使用 Python 3。我已经安装了 Python2 和 Python3。

[root@ansible1 ~]# python --version
Python 2.7.5
[root@ansible1 ~]# python3 --version
Python 3.6.8

如果我使用 安装 Ansible yum install ansible,该ansible --version命令显示 Ansible 已配置为使用 Python 2.7.5。我卸载 ansible ( yum remove ansible);

[root@ansible1 ~]# ansible --version
ansible 2.9.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

根据https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html:

在 Python 3 下运行 /usr/bin/ansible 最简单的方法是使用 Python3 版本的 pip 安装它。这将使默认的 /usr/bin/ansible 与 Python3 一起运行

我安装了 9.0.3 版本的 pip。

[root@ansible1 ~]# pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

按照 Ansibles 文档,我pip3 install ansible使用 pip3 安装 Ansible。

[root@ansible1 ~]# pip3 install ansible
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting ansible
  Using cached https://files.pythonhosted.org/packages/4b/69/c8aef60ce070fe6872e27db65f588bd0ffe8892a980cd3f4d844d8b72152/ansible-2.9.12.tar.gz
Requirement already satisfied: jinja2 in /usr/local/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: PyYAML in /usr/local/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: cryptography in /usr/local/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.6/site-packages (from jinja2->ansible)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in /usr/local/lib64/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: pycparser in /usr/local/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.8->cryptography->ansible)
Installing collected packages: ansible
  Running setup.py install for ansible ... done
Successfully installed ansible-2.9.12

这是pip3 show ansible命令的输出。

[root@ansible1 ~]# pip3 show ansible
Name: ansible
Version: 2.9.12
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/local/lib/python3.6/site-packages
Requires: jinja2, PyYAML, cryptography

但是,该ansible --version命令返回以下内容。

-bash: /bin/ansible: No such file or directory

同样,/usr/bin/ansible --version:

-bash: /usr/bin/ansible: No such file or directory

该pip show ansible命令显示位置是/usr/local/lib/python3.6/site-packages/ansible。该目录存在,并且包含许多文件和文件夹,但没有可以使用的 Ansible 特定配置文件(例如 ansible.cfg)或二进制文件(例如 ansible)(我能说的最好)。

python pip ansible
  • 1 1 个回答
  • 8921 Views

1 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2020-08-18T02:39:00+08:002020-08-18T02:39:00+08:00

    Bash缓存 commands 的路径,如果命令被重新定位(就像您的情况一样),除非清除缓存,否则 bash 将不会拾取它。

    ansible您可以使用以下命令从缓存中清除:

    hash -d ansible
    

    或清除整个缓存:

    hash -r
    
    • 10

相关问题

  • 在 cygwin/XP 下安装完整 Python 的最佳方式?

  • Mac OS X:从 python 脚本中更改 $PATH

  • 可以使用 easy_install 和 bdist_rpm 安装吗?

  • 我可以“注册”python 脚本以在 Windows 上执行吗?

  • 如何使用脚本远程重启 Windows 服务?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve