我已经按照 ansible 文档的建议使用 pip 在我的 Mac 上安装了 ansible:https ://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-macos
但是,当我尝试运行 ansible 时,我得到以下信息:
zsh: command not found: ansible
我以前安装ansible时从未遇到过这个问题。
pip-installing 再次告诉我它已经安装在站点包下:
Requirement already satisfied: ansible in ./Library/Python/3.8/lib/python/site-packages (2.9.11)
我在 ~/.zshrc 中的 python 安装指向:
# Add user python 3.7 to path
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)
对某些人来说可能很明显,但我不明白为什么这个简单的安装不起作用..
小智 11
用 安装ansible 后python3 -m pip install --user ansible,我搜索了ansible 二进制文件,发现它可以下载到~/Library/Python/3.8/bin. 最简单的方法是解决这个问题:
$ cd ~
$ find . | grep ansible
<lines omitted>
./Library/Python/3.8/bin/ansible
<lines omitted>
Run Code Online (Sandbox Code Playgroud)
从那里开始,它非常简单,只需更新您的 .bash_profile 或 .zshrc
export PATH="/path/to/Library/Python/3.8/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)
你应该很高兴去:
$ source ~/.zshrc
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/Users/dbove/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
Run Code Online (Sandbox Code Playgroud)
小智 6
以下命令对我有用:
卸载ansible
sudo pip 卸载 ansible
然后使用安装(注意:-H 标志在这里很重要,它将 HOME 变量设置为目标用户的主目录)
sudo -H pip3 安装 ansible
使用检查版本
ansible --版本
小智 5
brew install ansible
brew link ansible
小智 5
安装后如:
python3 -m pip install --user ansible
Run Code Online (Sandbox Code Playgroud)
编辑.zshrc:
export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
你应该添加$HOME/.local/bin.
| 归档时间: |
|
| 查看次数: |
7639 次 |
| 最近记录: |