当前位置 博文首页 > yunweigo的博客:ERROR: Could not build wheels for cryptograp

    yunweigo的博客:ERROR: Could not build wheels for cryptograp

    作者:[db:作者] 时间:2021-07-15 12:35

    笔者是在对接阿里云使用阿里的SDK时出现的问题

    解决方案

    https://cryptography.io/en/latest/installation/

    $ apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
    $ pip install --upgrade pip
    $ export CRYPTOGRAPHY_DONT_BUILD_RUST=1
    $ pip install cryptography
    

    解决过程

          =============================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't find Rust compiler
    
      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.
    
      To update pip, run:
    
          pip install --upgrade pip
    
      and then retry package installation.
    
      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
    
      This package requires Rust >=1.41.0.
      ----------------------------------------
      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
    

    发现上面给出了解决方案:

          =============================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=============================
    
    ============================= 调试援助 =============================
    如果看到编译错误,请尝试以下步骤
    成功安装加密:
    1)升级到最新的pip再试一次。这将修复大多数错误
    用户。见:https://pip.pypa.io/en/stable/installing/ upgrading-pip
    2)具体阅读https://cryptography.io/en/latest/installation.html
    你的平台说明。
    3)查看我们的常见问题,了解更多信息:
    https://cryptography.io/en/latest/faq.html
    4)确保你最近安装了Rust工具链:
    https://cryptography.io/en/latest/installation.html#rust
    5)如果您在*此版本*中遇到Rust问题,您可以
    设置环境变量' CRYPTOGRAPHY_DONT_BUILD_RUST=1 '============================= 调试援助 =============================
    

    首先先升级pip

    pip install --upgrade pip
    

    我升级完之后重新安装还是报错(网上有的人已经解决了, 如果你已经解决忽略后面内容)

    继续看上面的内容, 说我Rust版本太低了
    查看官网需要安装相关依赖

    https://cryptography.io/en/latest/installation/

    sudo apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
    

    重新安装还是报错, 继续按照指示来继续处理

         ERROR: Command errored out with exit status 1:
         command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-km3x31je/matplotlib_fcb1836ff32b459797e98afb66f6211e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-km3x31je/matplotlib_fcb1836ff32b459797e98afb66f6211e/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-7833r8p7
             cwd: /tmp/pip-install-km3x31je/matplotlib_fcb1836ff32b459797e98afb66f6211e/
        Complete output (44 lines):
        WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
        ERROR: Could not find a version that satisfies the requirement numpy>=1.16 (from versions: none)
        ERROR: No matching distribution found for numpy>=1.16
        Traceback (most recent call last):
          File "/usr/local/lib/python3.7/site-packages/setuptools/installer.py", line 75, in fetch_build_egg
            subprocess.check_call(cmd)
          File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
            raise CalledProcessError(retcode, cmd)
        subprocess.CalledProcessError: Command '['/usr/local/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpd6d05k3_', '--quiet', 'numpy>=1.16']' returned non-zero exit status 1.
    
        The above exception was the direct cause of the following exception:
    
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-km3x31je/matplotlib_fcb1836ff32b459797e98afb66f6211e/setup.py", line 314, in <module>
            cmdclass=cmdclass,
          File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 152, in setup
            _install_setup_requires(attrs)
          File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 147, in _install_setup_requires
            dist.fetch_build_eggs(dist.setup_requires)
          File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 782, in fetch_build_eggs
            replace_conflicting=True,
          File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 768, in resolve
            replace_conflicting=replace_conflicting
          File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1051, in best_match
            return self.obtain(req, installer)
          File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1063, in obtain
            return installer(requirement)
          File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 838, in fetch_build_egg
            return fetch_build_egg(self, req)
          File "/usr/local/lib/python3.7/site-packages/setuptools/installer.py", line 77, in fetch_build_egg
            raise DistutilsError(str(e)) from e
        distutils.errors.DistutilsError: Command '['/usr/local/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpd6d05k3_', '--quiet', 'numpy>=1.16']' returned non-zero exit status 1.
    
        Edit setup.cfg to change the build options; suppress output with --quiet.
    
        BUILDING MATPLOTLIB
          matplotlib: yes [3.4.2]
              python: yes [3.7.10 (default, Jun 29 2021, 01:54:47)  [GCC 10.3.1
                          20210424]]
            platform: yes [linux]
               tests: no  [skipping due to configuration]
              macosx: no  [Mac OS-X only]
    
    

    设置环境变量

    export CRYPTOGRAPHY_DONT_BUILD_RUST=1
    pip install cryptography
    

    这次成功了。

    cs
    下一篇:没有了