使用pip
安装依赖的时候,更新之后,更新的依赖不能用。比如我将机器的ansible
版本指定安装2.7.11
版本,安装成功之后,使用命令ansible --version
的时候,提示报错,报错具体提示如下:
(相关资料图)
ERROR! Unexpected Exception, this is probably a bug: name "platform_system" is not definedthe full traceback was:Traceback (most recent call last): File "/bin/ansible", line 97, inmycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass) File "/usr/lib/python2.7/site-packages/ansible/cli/__init__.py", line 38, in from ansible.inventory.manager import InventoryManager File "/usr/lib/python2.7/site-packages/ansible/inventory/manager.py", line 38, in from ansible.plugins.loader import inventory_loader File "/usr/lib/python2.7/site-packages/ansible/plugins/loader.py", line 22, in from ansible.parsing.utils.yaml import from_yaml File "/usr/lib/python2.7/site-packages/ansible/parsing/utils/yaml.py", line 17, in from ansible.parsing.yaml.loader import AnsibleLoader File "/usr/lib/python2.7/site-packages/ansible/parsing/yaml/loader.py", line 30, in from ansible.parsing.yaml.constructor import AnsibleConstructor File "/usr/lib/python2.7/site-packages/ansible/parsing/yaml/constructor.py", line 29, in from ansible.parsing.vault import VaultLib File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 42, in from cryptography.hazmat.backends import default_backend File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in import pkg_resources File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3007, in working_set.require(__requires__) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 728, in require needed = self.resolve(parse_requirements(requirements)) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 631, in resolve requirements.extend(dist.requires(req.extras)[::-1]) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2489, in requires dm = self._dep_map File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2700, in _dep_map self.__dep_map = self._compute_dependencies() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2733, in _compute_dependencies common = frozenset(reqs_for_extra(None)) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2730, in reqs_for_extra if req.marker_fn(override={"extra":extra}): File "/usr/lib/python2.7/site-packages/_markerlib/markers.py", line 113, in marker_fn return eval(compiled_marker, environment) File " ", line 1, in NameError: name "platform_system" is not defined
软件 | 版本 |
python | 2.7 |
pip | 8.1.2 |
setuptools | 0.9.8 |
指定软件版本进行更新的时候,软件本身依赖的setuptools
版本不兼容当前机器的版本。所以更新setuptools
依赖即可。不过为了保险起见,最好连pip
都一起更新。
使用root
用户执行以下命令
pip install --upgrade pippip install --upgrade setuptools
使用命令ansible --version
命令之后,可以正常显示,如下:
ansible 2.7.11 config file = /home/tidb/tidb-ansible/ansible.cfg configured module search path = [u"/home/tidb/.ansible/plugins/modules", u"/usr/share/ansible/plugins/modules"] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /bin/ansible python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
版本依赖冲突是一个比较常见的问题,主要是分析背后的依赖问题,根据具体情况即可解决问题。
如果我的文章对大家产生了帮忙,可以在文章底部点个赞或者收藏;如果有好的讨论,可以留言;如果想继续查看我以后的文章,可以左上角点击关注
也可以扫描以下二维码,关注我的公众号:枫夜之求索阁,查看我最新的分享!