ansible 部署安装 python 依赖包时报错 No module named setuptools_rust

为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:

【TiDB 版本】

TiDB v2.1.19

【问题描述】
生产环境准备做修改IP操作,虚机模式时发现,使用 ansible 部署 TiDB 2.1.19 在安装 ansible 依赖环境时出现错误 ImportError: No module named setuptools_rust

操作步骤参考 官网文档-ansible 离线部署 ,之前我使用 ansible 安装过 3 版本并未出现问题,而且这还是安装依赖阶段,按理说不应该出错,求解?

尝试如下:

  • 尝试过在线安装,同样报错,放弃;

  • pip install --upgrade pip 升级 pip 后,会报 ansible sys.stderr.write(f"ERROR: {exc}") ,放弃;

  • 尝试取 github 下载 setuptools-rust 手动 build,发现好像只能用 python3 去build,相关步骤如下,而且官网的步骤 python 依赖的是 python 2.7,所以未继续尝试,放弃;

       [tidb@localhost setuptools-rust]$ python3 setup.py install --user
       Traceback (most recent call last):
         File "setup.py", line 6, in <module>
           setup()
         ......
         ......
         File "/home/tidb/setuptools-rust/setuptools_rust/utils.py", line 6, in <module>
           import semantic_version
       ModuleNotFoundError: No module named 'semantic_version'
    
  • 操作系统环境

     [tidb@localhost ~]$ cat /etc/*leas* |grep NAME
     NAME="CentOS Linux"
     PRETTY_NAME="CentOS Linux 7 (Core)"
     CPE_NAME="cpe:/o:centos:centos:7"
     [tidb@localhost ~]$ uname -a
     Linux localhost.localdomain 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    
  • 依据官网步骤执行如下:

     tar -xzvf ansible-system-rpms.el7.tar.gz 
     chmod u+x install_ansible_system_rpms.sh &&
     ./install_ansible_system_rpms.sh
     
     
     pip -V
     pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
     
     visudo
     tidb ALL=(ALL) NOPASSWD: ALL
     
     
     # !!!此步骤后直接报错!!!!
     
     [tidb@localhost tidb-ansible]$ sudo pip install -r ./requirements.txt
     Collecting ansible<2.7.0,>=2.4.2 (from -r ./requirements.txt (line 1))
       Downloading https://files.pythonhosted.org/packages/b1/da/6c8f2daff9b776a85eff1ab1ac9bbf3bc67f9e55fa616b4d45dab76fef90/ansible-2.6.20.tar.gz (10.8MB)
         100% |████████████████████████████████| 10.8MB 141kB/s 
     Collecting jinja2>=2.9.6 (from -r ./requirements.txt (line 2))
       Downloading https://files.pythonhosted.org/packages/7e/c2/1eece8c95ddbc9b1aeb64f5783a9e07a286de42191b7204d67b7496ddf35/Jinja2-2.11.3-py2.py3-none-any.whl (125kB)
         100% |████████████████████████████████| 133kB 2.6MB/s 
     Collecting jmespath>=0.9.0 (from -r ./requirements.txt (line 3))
       Downloading https://files.pythonhosted.org/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl
     Collecting PyYAML (from ansible<2.7.0,>=2.4.2->-r ./requirements.txt (line 1))
       Downloading https://files.pythonhosted.org/packages/ba/d4/3cf562876e0cda0405e65d351b835077ab13990e5b92912ef2bf1a2280e0/PyYAML-5.4.1-cp27-cp27mu-manylinux1_x86_64.whl (574kB)
         100% |████████████████████████████████| 583kB 1.6MB/s 
     Collecting paramiko (from ansible<2.7.0,>=2.4.2->-r ./requirements.txt (line 1))
       Downloading https://files.pythonhosted.org/packages/95/19/124e9287b43e6ff3ebb9cdea3e5e8e88475a873c05ccdf8b7e20d2c4201e/paramiko-2.7.2-py2.py3-none-any.whl (206kB)
         100% |████████████████████████████████| 215kB 3.4MB/s 
     Collecting cryptography (from ansible<2.7.0,>=2.4.2->-r ./requirements.txt (line 1))
       Downloading https://files.pythonhosted.org/packages/fa/2d/2154d8cb773064570f48ec0b60258a4522490fcb115a6c7c9423482ca993/cryptography-3.4.6.tar.gz (546kB)
         100% |████████████████████████████████| 552kB 2.0MB/s 
         Complete output from command python setup.py egg_info:
         
                 =============================DEBUG ASSISTANCE==========================
                 If you are seeing an error here please try the following to
                 successfully install cryptography:
         
                 Upgrade to the latest pip and try again. This will fix errors for most
                 users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
                 =============================DEBUG ASSISTANCE==========================
         
         Traceback (most recent call last):
           File "<string>", line 1, in <module>
           File "/tmp/pip-build-IKFaNk/cryptography/setup.py", line 14, in <module>
             from setuptools_rust import RustExtension
         ImportError: No module named setuptools_rust
         
         ----------------------------------------
     Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-IKFaNk/cryptography/
     You are using pip version 8.1.2, however version 21.0.1 is available.
     You should consider upgrading via the 'pip install --upgrade pip' command.
     [tidb@localhost tidb-ansible]$ pip install -r setuptools-rust setuptools wheel
     Could not open requirements file: [Errno 2] No such file or directory: 'setuptools-rust'
     You are using pip version 8.1.2, however version 21.0.1 is available.
     You should consider upgrading via the 'pip install --upgrade pip' command.
    

感觉我操作并未出错,且之前有成功案例, TIDB 官方已经不维护 ansible 了,是不是官网的操作步骤不适用现在情况了?这种情况如何解决?


若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。

官方文档-ansible 部署 中有一句话: 请按以下方式在 CentOS 7 系统的下载机上在线安装 TiDB Ansible。安装完成后,可通过 ansible --version 查看版本,请务必确认是 Ansible 2.5.0 版本,否则会有兼容问题。

版本有点低了,强烈建议升级版本。

嗯,有升级规划

:handshake:

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。