已安装pywinrm,仍报错winrm or requests is not installed: No module named winrm

问题描述:
ansible 调用远程widows服务器,执行报错
报错信息:
winrm or requests is not installed: No module named winrm

环境:
ansible版本:ansible 2.9.27 #yum安装
python版本:python version = 2.7.5 #系统默认
同时系统上安装了python3.6.8 #yum安装
系统没有安装pip2,ansible默认使用的python2
并且由于python2已经弃用,即使安装pip2后,任然无法安装pywinrm,报错如下

python -m pip install  pywinrm-0.4.3-py2.py3-none-any.whl
Processing ./pywinrm-0.4.3-py2.py3-none-any.whl
Collecting xmltodict (from pywinrm==0.4.3)
  Using cached https://files.pythonhosted.org/packages/94/db/fd0326e331726f07ff7f40675cd86aa804bfd2e5016c727fa761c934990e/xmltodict-0.13.0-py2.py3-none-any.whl
Collecting requests>=2.9.1 (from pywinrm==0.4.3)
  Using cached https://files.pythonhosted.org/packages/a5/61/a867851fd5ab77277495a8709ddda0861b28163c4613b011bc00228cc724/requests-2.28.1.tar.gz
    Complete output from command python setup.py egg_info:

    ==========================
    Unsupported Python version
    ==========================
    This version of Requests requires at least Python 3.7, but
    you're trying to install it on Python 2.7. To resolve this,
    consider upgrading to a supported Python version.

    If you can't upgrade your Python version, you'll need to
    pin to an older version of Requests (<2.28).

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zToSeV/requests/
You are using pip version 8.1.2, however version 22.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

因此用pip3安装了pywinrm,并且执行ansible时指定了python3作为解释环境,但是在这里并没有起作用

ansible -i hosts rwin  -m win_ping -e 'ansible_python_interpreter=/usr/bin/python3'

解决办法:
升级ansible版本:

python3 -m pip install  ansible 
source /etc/profile
ansible --vesion
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值