ERROR: Failed building wheel for cryptography


debian下python3.9安裝cryptography報錯

完整錯誤信息:

running build_rust
  
      =============================DEBUG ASSISTANCE=============================
      If you are seeing a compilation error please try the following steps to
      successfully install cryptography:
      1) 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
      2) Read https://cryptography.io/en/latest/installation.html for specific
         instructions for your platform.
      3) Check our frequently asked questions for more information:
         https://cryptography.io/en/latest/faq.html
      4) Ensure you have a recent Rust toolchain installed:
         https://cryptography.io/en/latest/installation.html#rust
      5) If you are experiencing issues with Rust for *this release only* you may
         set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
      =============================DEBUG ASSISTANCE=============================
  
  error: Can not find Rust compiler
  ----------------------------------------
  ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

首先確保一些依賴包已經正常安裝

sudo apt-get update

sudo apt-get upgrade

sudo apt-get dist-upgrade

sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus

sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev

sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev

sudo apt-get install libssl-dev openssl

sudo apt-get install libffi-dev

確認依賴沒問題后可以嘗試以下三種解決方式:

  1. 升級pip后再試
    python -m pip install --upgrade pip

如果發現升級失敗可以刪除
"/你的安裝目錄/site-packages/pip-你的版本號.dist-info" 目錄重新執行 python -m pip install --upgrade pip 再試

  1. 先安裝pep517再安裝cryptography
pip install pep517
pip install cryptography
  1. 直接忽略build rust編譯器
export CRYPTOGRAPHY_DONT_BUILD_RUST=1
pip install cryptography


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM