【问题标题】:Ansible command always show SETUPTOOLS WILL STOP WORKING warningAnsible 命令总是显示 SETUPTOOLS 将停止工作警告
【发布时间】:2020-03-27 07:52:01
【问题描述】:

ansible 命令总是在下面打印警告:

/usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please comment in
https://github.com/pypa/setuptools/issues/1458
about the steps that led to this unsupported combination.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)

系统信息:ubuntu 16.04

安装方法:apt-get install ansible

我怎样才能摆脱这个警告?

提示:ansible 似乎使用/usr/bin/python,这是 ubuntu 环境中默认的python2.7

【问题讨论】:

    标签: python ubuntu ansible setuptools


    【解决方案1】:

    又快又脏的方式:

    编辑/usr/bin/ansible

    添加代码:

    import warnings
    warnings.filterwarnings("ignore")
    

    但是有没有更好的方法让ansible使用python3环境?

    更好的方法

    1. 使用pyenv或其他工具安装python3

    2. 确保运行 /usr/bin/env python 运行 python3

    3. 编辑/usr/bin/ansible

    #!/usr/bin/python -&gt; #!/usr/bin/env python

    1. 使用pip install ansble 安装缺少的包。

    否则会显示ansible module not found 错误。

    【讨论】:

      猜你喜欢
      • 2020-06-11
      • 2016-01-29
      • 2022-01-17
      • 1970-01-01
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-03
      相关资源
      最近更新 更多