Ansible使用Python3 pip安装问题

huangapple go评论66阅读模式
英文:

ansible install issue using python3 pip

问题

看到问题是找不到已安装的Ansible软件包。

按照以下链接进行操作:

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

尝试运行如上链接所示的命令,下面是我在环境中得到的结果。

$ python3 -m pip -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

而且使用 python3 -m pip install --user ansible 安装软件包看起来也没问题,输出如下:

$ python3 -m pip show ansible
Name: ansible
Version: 4.10.0
Summary: 彻底简化的IT自动化
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: info@ansible.com
License: GPLv3+
Location: /home/ansible/.local/lib/python3.6/site-packages
Requires: ansible-core

但是当我运行以下命令时,无法在PATH中找到:

ansible --version
bash: /bin/ansible: 没有该文件或目录

是否需要以不同的方式引用pip3软件包以访问Ansible软件包?在 /bin/ansible/usr/bin/ansible 下看不到任何东西。

英文:

Seeing issue locating installed Ansible package.

Following along

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

Tried running commands as per above link & below is what I got in the environment.

$ python3 -m pip -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

And installation of package just looks ok on python3 -m pip install --user ansible as well & output shows like below:

$ python3 -m pip show ansible
Name: ansible
Version: 4.10.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: info@ansible.com
License: GPLv3+
Location: /home/ansible/.local/lib/python3.6/site-packages
Requires: ansible-core

But when I run below, its not able to find in PATH

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

Does pip3 packages needs to be referenced in different way to access Ansible pacakge?. Don't see anything under /bin/ansible or /usr/bin/ansible

答案1

得分: 2

如果您通过非根用户运行以下命令来安装 Ansible:

那么 Ansible 将不会安装到 /bin 目录中。在Linux系统上,它可能会安装到 $HOME/.local/bin 目录中,为了使shell在命令行中输入 ansible 时能找到它,需要将该目录添加到您的 $PATH 中。

您可以通过运行以下命令临时更新您的路径:

要永久更新您的 $PATH,您需要修改您的shell的初始化文件。如果您使用Bash,这将是 $HOME/.profile$HOME/.bash_profile,取决于哪个文件存在。

英文:

If you installed Ansible by running, as a non-root user:

python3 -m pip install --user ansible

Then Ansible wasn't installed into /bin. On a Linux system, it would probably end up in $HOME/.local/bin, which would need to be in your $PATH in order to the shell to find it when you type ansible on the command line.

You can temporarily update your path by running:

PATH="$HOME/.local/bin:$PATH"

To permanently update your $PATH, you would need to modify your shell's initialization files. If you're using Bash, that's going to be $HOME/.profile or $HOME/.bash_profile, whichever exists.

答案2

得分: 0

PATH 需要通过显式引用 .bash_profile 来设置/引用。

This solved the problem!.

As with --user it creates .local/ site-packages lib.

PATH=$PATH:$HOME/.local/bin:$HOME/bin

英文:

PATH needs to be set/referenced by sourcing .bash_profile explicitly.

This solved the problem!.

As with --user it creates .local/ site-packages lib.

PATH=$PATH:$HOME/.local/bin:$HOME/bin

huangapple
  • 本文由 发表于 2023年4月10日 22:52:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75978141.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定