首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pip3安装失败

pip3安装失败
EN

Server Fault用户
提问于 2020-08-17 10:13:29
回答 1查看 10.7K关注 0票数 7

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

代码语言:javascript
复制
[root@ansible1 ~]# python --version
Python 2.7.5
[root@ansible1 ~]# python3 --version
Python 3.6.8

如果我使用yum install ansible安装Ansible,则ansible --version命令将显示Ansible配置为使用Python2.7.5。我卸载ansible (yum remove ansible);

代码语言:javascript
复制
[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_附录/蟒蛇_3._support.html的说法:

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

我安装了9.0.3版本的pip。

代码语言:javascript
复制
[root@ansible1 ~]# pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

在Ansible文档之后,我发布pip3 install ansible来使用pip3安装Ansible。

代码语言:javascript
复制
[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命令的输出。

代码语言:javascript
复制
[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: info@ansible.com
License: GPLv3+
Location: /usr/local/lib/python3.6/site-packages
Requires: jinja2, PyYAML, cryptography

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

代码语言:javascript
复制
-bash: /bin/ansible: No such file or directory

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

代码语言:javascript
复制
-bash: /usr/bin/ansible: No such file or directory

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

EN

回答 1

Server Fault用户

回答已采纳

发布于 2020-08-17 10:39:00

Bash 缓存到命令的路径。,如果重新定位了一个命令(在您的例子中似乎是这样),则bash将不会将其捕获,除非清除该缓存。

您可以使用以下方法从缓存中清除ansible

代码语言:javascript
复制
hash -d ansible

或使用以下方法清除整个缓存:

代码语言:javascript
复制
hash -r
票数 12
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1030419

复制
相关文章

相似问题

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