Ansible命令始终显示SETUPTOOLS WILL STOP WORKING警告

时间:2020-03-27 07:52:01

标签: python ubuntu ansible setuptools

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

1 个答案:

答案 0 :(得分:0)

快速而肮脏的方式:

编辑/usr/bin/ansible

添加代码:

import warnings
warnings.filterwarnings("ignore")

但是还有更好的方法来使用python3环境吗?

更好的方式

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

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

  3. 编辑/usr/bin/ansible

#!/usr/bin/python -> #!/usr/bin/env python

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

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