You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7使用pip3安装paramiko报No module named 'setuptools_rust'

CentOS 7 pip安装paramiko报错解决

问题场景

在CentOS 7系统中,先通过yum命令安装python3环境:

yum install -y python3

后续执行pip3 install paramiko安装paramiko库时触发报错,核心报错信息为安装依赖cryptography时提示ModuleNotFoundError: No module named 'setuptools_rust',完整安装失败日志如下:

[root@test ~]# pip3 install paramiko
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting paramiko
  Using cached https://files.pythonhosted.org/packages/04/e5/39ec73dd4a8769d6759b8d6c60a1b2c9337f585407c2ae8bfb8ccb734278/paramiko-2.11.0-py2.py3-none-any.whl
Collecting cryptography>=2.5 (from paramiko)
  Using cached https://files.pythonhosted.org/packages/51/05/bb2b681f6a77276fc423d04187c39dafdb65b799c8d87b62ca82659f9ead/cryptography-37.0.2.tar.gz
    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.
            =============================DEBUG ASSISTANCE==========================
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-ccbam6fs/cryptography/setup.py", line 14, in <module>
        from setuptools_rust import RustExtension
    ModuleNotFoundError: No module named 'setuptools_rust'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ccbam6fs/cryptography/

报错原因

  • CentOS 7 yum源自带的pip3版本过旧,无法正确解析高版本cryptography的依赖关系
  • 37.0.0及以上版本的cryptography库依赖Rust编译环境和setuptools_rust组件,默认环境未预装这些依赖,拉取源码包编译时直接失败

解决方案

两种方案可选,按需使用即可:

方案一:安装依赖后使用最新版paramiko

按顺序执行以下命令:

  1. 升级pip并安装缺失的python依赖
pip3 install --upgrade pip setuptools_rust
  1. 安装cryptography编译所需的系统级依赖
yum install -y python3-devel libffi-devel openssl-devel gcc
  1. 重新执行paramiko安装命令
pip3 install paramiko

方案二:安装兼容旧环境的低版本paramiko(无需额外编译依赖)

如果不需要使用最新版paramiko的特性,直接安装不需要Rust依赖的2.8.1版本即可,不需要额外装其他依赖,执行单条命令即可完成安装:

pip3 install paramiko==2.8.1

内容的提问来源于stack exchange,提问作者Nanda Thota

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.30 07:03:16