首页 > 解决方案 > 即使显示成功,Ansible 也没有升级

问题描述

我运行以下命令来升级 Ansible(我在 2.8.4 上):

s-MacBook-Pro:~ albertski$ sudo pip install ansible --upgrade
Password:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/Users/albertski/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/albertski/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ansible
  Downloading https://files.pythonhosted.org/packages/04/25/48fee5f8048360d9375e01846fcf395dda58242ed1f25a2106b6794452eb/ansible-2.8.5.tar.gz (14.4MB)
     |████████████████████████████████| 14.4MB 14.7MB/s
Requirement already satisfied, skipping upgrade: jinja2 in /Library/Python/2.7/site-packages (from ansible) (2.10)
Requirement already satisfied, skipping upgrade: PyYAML in /Library/Python/2.7/site-packages (from ansible) (3.13)
Requirement already satisfied, skipping upgrade: cryptography in /Library/Python/2.7/site-packages (from ansible) (2.4.2)
Requirement already satisfied, skipping upgrade: MarkupSafe>=0.23 in /Library/Python/2.7/site-packages (from jinja2->ansible) (1.1.0)
Requirement already satisfied, skipping upgrade: six>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography->ansible) (1.11.0)
Requirement already satisfied, skipping upgrade: cffi!=1.11.3,>=1.7 in /Library/Python/2.7/site-packages (from cryptography->ansible) (1.11.5)
Requirement already satisfied, skipping upgrade: enum34; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography->ansible) (1.1.6)
Requirement already satisfied, skipping upgrade: idna>=2.1 in /Library/Python/2.7/site-packages (from cryptography->ansible) (2.7)
Requirement already satisfied, skipping upgrade: asn1crypto>=0.21.0 in /Library/Python/2.7/site-packages (from cryptography->ansible) (0.24.0)
Requirement already satisfied, skipping upgrade: ipaddress; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography->ansible) (1.0.22)
Requirement already satisfied, skipping upgrade: pycparser in /Library/Python/2.7/site-packages (from cffi!=1.11.3,>=1.7->cryptography->ansible) (2.19)
Installing collected packages: ansible
  Found existing installation: ansible 2.7.13
    Uninstalling ansible-2.7.13:
      Successfully uninstalled ansible-2.7.13
  Running setup.py install for ansible ... done
Successfully installed ansible-2.8.5

它显示在最后Successfully installed ansible-2.8.5

当我检查版本时,它仍然显示 2.8.4。

Alberts-MacBook-Pro:~ albertski$ ansible --version
ansible 2.8.4
  config file = /Users/albertski/.ansible.cfg
  configured module search path = ['/Users/albertski/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible
  executable location = /Library/Frameworks/Python.framework/Versions/3.7/bin/ansible
  python version = 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28) [Clang 6.0 (clang-600.0.57)]

编辑

试图降级到 2.7.13,我遇到了同样的问题:

sudo pip install ansible==2.7.13
Password:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/Users/albertski/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/albertski/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ansible==2.7.13
  Downloading https://files.pythonhosted.org/packages/71/25/90546592a692fcb8b3e6e578e743dcba19f1ecdb2ef47860dc5bf0a828aa/ansible-2.7.13.tar.gz (11.9MB)
     |████████████████████████████████| 11.9MB 7.7MB/s
Requirement already satisfied: jinja2 in /Library/Python/2.7/site-packages (from ansible==2.7.13) (2.10)
Requirement already satisfied: PyYAML in /Library/Python/2.7/site-packages (from ansible==2.7.13) (3.13)
Requirement already satisfied: paramiko in /Library/Python/2.7/site-packages (from ansible==2.7.13) (2.4.2)
Requirement already satisfied: cryptography in /Library/Python/2.7/site-packages (from ansible==2.7.13) (2.4.2)
Requirement already satisfied: setuptools in /Library/Python/2.7/site-packages (from ansible==2.7.13) (40.6.2)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Python/2.7/site-packages (from jinja2->ansible==2.7.13) (1.1.0)
Requirement already satisfied: pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko->ansible==2.7.13) (0.4.4)
Requirement already satisfied: bcrypt>=3.1.3 in /Library/Python/2.7/site-packages (from paramiko->ansible==2.7.13) (3.1.4)
Requirement already satisfied: pynacl>=1.0.1 in /Library/Python/2.7/site-packages (from paramiko->ansible==2.7.13) (1.3.0)
Requirement already satisfied: six>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography->ansible==2.7.13) (1.11.0)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in /Library/Python/2.7/site-packages (from cryptography->ansible==2.7.13) (1.11.5)
Requirement already satisfied: enum34; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography->ansible==2.7.13) (1.1.6)
Requirement already satisfied: idna>=2.1 in /Library/Python/2.7/site-packages (from cryptography->ansible==2.7.13) (2.7)
Requirement already satisfied: asn1crypto>=0.21.0 in /Library/Python/2.7/site-packages (from cryptography->ansible==2.7.13) (0.24.0)
Requirement already satisfied: ipaddress; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography->ansible==2.7.13) (1.0.22)
Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi!=1.11.3,>=1.7->cryptography->ansible==2.7.13) (2.19)
Installing collected packages: ansible
  Found existing installation: ansible 2.8.5
    Uninstalling ansible-2.8.5:
      Successfully uninstalled ansible-2.8.5
  Running setup.py install for ansible ... done
Successfully installed ansible-2.7.13
Alberts-MacBook-Pro:ansible albertski$ ansible --version
ansible 2.8.4
  config file = /Users/albertski/Sites/ansible/ansible.cfg
  configured module search path = ['/Users/albertski/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible
  executable location = /Library/Frameworks/Python.framework/Versions/3.7/bin/ansible
  python version = 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28) [Clang 6.0 (clang-600.0.57)]

操作系统:OSX Mojave

标签: ansible

解决方案


您正在使用 python2 pip 安装 Ansible,而您的 shell 路径中的 Ansible 似乎正在使用 python3。

尝试以下操作: sudo pip3 install ansible --upgrade

或者更好的是,将其保存在您的用户主目录中

pip3 install --user ansible --upgrade


推荐阅读