Ansible更新仍显示旧版本

时间:2017-06-29 14:23:31

标签: python pip ansible

我在Debian 8服务器上将ansible从2.0版升级到2.3.1,并按照Ansible提供的说明进行操作:

  1. 添加到来源列表: deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

  2. 运行以下命令:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 sudo apt-get update sudo apt-get install ansible

  3. 我检查了which ansible,显示要指向/ usr / local / bin。 当我运行echo $ PATH时,我看到列出了/ usr / local / bin。我是否需要运行额外的步骤才能获得正确的Ansible版本?

    我没有输出。但是当我运行apt时,它成功更新为ansible 2.3.1

    更新:ansible最初是通过pip安装的。当我运行`pip install --upgrade ansible时,我得到:

      Running setup.py (path:/tmp/pip-build-jyjjV6/cryptography/setup.py) egg_info for package cryptography
    
        no previously-included directories found matching 'docs/_build'
        warning: no previously-included files matching '*' found under directory 'vectors'
    Downloading/unpacking pynacl>=1.0.1 (from paramiko->ansible)
      Downloading PyNaCl-1.1.2.tar.gz (3.1MB): 3.1MB downloaded
      Running setup.py (path:/tmp/pip-build-jyjjV6/pynacl/setup.py) egg_info for package pynacl
        c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
         #include <ffi.h>
                         ^
        compilation terminated.
        Traceback (most recent call last):
          File "<string>", line 17, in <module>
          File "/tmp/pip-build-jyjjV6/pynacl/setup.py", line 232, in <module>
            "Programming Language :: Python :: 3.6",
          File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
            _setup_distribution = dist = klass(attrs)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 268, in __init__
            self.fetch_build_eggs(attrs['setup_requires'])
          File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 312, in fetch_build_eggs
            replace_conflicting=True,
          File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 846, in resolve
            dist = best[req.key] = env.best_match(req, ws, installer)
          File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1091, in best_match
            return self.obtain(req, installer)
          File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1103, in obtain
            return installer(requirement)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 379, in fetch_build_egg
            return cmd.easy_install(req)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 639, in easy_install
            return self.install_item(spec, dist.location, tmpdir, deps)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 669, in install_item
            dists = self.install_eggs(spec, download, tmpdir)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 852, in install_eggs
            return self.build_and_install(setup_script, setup_base)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1080, in build_and_install
            self.run_setup(setup_script, setup_base, args)
          File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1068, in run_setup
            raise DistutilsError("Setup script exited with %s" % (v.args[0],))
        distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
        Complete output from command python setup.py egg_info:
        c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
    
     #include <ffi.h>
    
                     ^
    
    compilation terminated.
    
    Traceback (most recent call last):
    
      File "<string>", line 17, in <module>
    
      File "/tmp/pip-build-jyjjV6/pynacl/setup.py", line 232, in <module>
    
        "Programming Language :: Python :: 3.6",
    
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
    
        _setup_distribution = dist = klass(attrs)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 268, in __init__
    
        self.fetch_build_eggs(attrs['setup_requires'])
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 312, in fetch_build_eggs
    
        replace_conflicting=True,
    
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 846, in resolve
    
        dist = best[req.key] = env.best_match(req, ws, installer)
    
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1091, in best_match
    
        return self.obtain(req, installer)
    
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1103, in obtain
    
        return installer(requirement)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 379, in fetch_build_egg
    
        return cmd.easy_install(req)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 639, in easy_install
    
        return self.install_item(spec, dist.location, tmpdir, deps)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 669, in install_item
    
        dists = self.install_eggs(spec, download, tmpdir)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 852, in install_eggs
    
        return self.build_and_install(setup_script, setup_base)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1080, in build_and_install
    
        self.run_setup(setup_script, setup_base, args)
    
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1068, in run_setup
    
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
    Cleaning up...
    Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-jyjjV6/pynacl
    Storing debug log for failure in /root/.pip/pip.log
    

    当我尝试运行apt-get install并运行/ usr / bin / ansible --version时,我得到了:

    Traceback (most recent call last):
      File "/usr/bin/ansible", line 46, in <module>
        from ansible.module_utils._text import to_text
    ImportError: No module named _text
    

    理想情况下,我想通过pip升级,但我似乎无法让它运行。我会决定使用apt-get。

2 个答案:

答案 0 :(得分:3)

DEB软件包在/usr/bin/ansible安装ansible,我想你之前的安装不是来自DEB软件包(而是pip而是?),它解释了为什么你有两个版本的ansible。 /> 根据您PATH的定义,您没有获得新版本。

您应该清除之前的安装(pip uninstall?)

更新:pip install --upgrade失败,因为它正在尝试构建一些ansible依赖项的C绑定。

您应该卸载随pip安装的版本,然后重新安装DEB包:

pip uninstall --yes ansible
apt install --yes --reinstall ansible

从系统包和pip混合安装绝不是一个好主意...

答案 1 :(得分:1)

在我的情况下,pip list | grep <package name>显示了新版本,但\usr\bin内的全局包(可能是由rpm安装)仍然是旧版本。通常,您可以使用<package name> --version检查全局包版本。

要解决此问题,我必须使用sudo进行升级:sudo pip install -U <package name>

或者如果在virtualenv内,请在没有sudo的情况下安装,但使用-I忽略全局包:

pip install -I <package name>