错误:无法为使用PEP 517且无法直接安装的scipy构建轮子

时间:2020-04-22 12:59:50

标签: python scipy pip embedded-linux python-wheel

我正在尝试通过pip在我的64位ARMV8板上安装scipy。我已经安装了scipy所需的openblas。因此,没有问题。当我给pip3 install scipy --trusted-host pypi.org --trusted-host files.pythonhosted.org时,出现错误 scipy的建筑轮子失败。我的/usr/bin中有pip3和pip3.5,其余的点位于/usr/lib64/python3.5/site-packages中。因此,基本上,我也有pip。

我还尝试使用--no-binary选项安装scipy,这是网络上的答案之一。但是,它给了我同样的错误。以下是我得到的错误。

错误:

Collecting scipy
  Downloading scipy-1.4.1.tar.gz (24.6 MB)
     |################################| 24.6 MB 6.6 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: scipy
  Building wheel for scipy (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/lib64/python3.5/site-packages/pip-20.0.2-py3.5.egg/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpkklsvv4v
       cwd: /tmp/pip-install-9v4nmof7/scipy
  Complete output (50 lines):
  /usr/bin/python3: No module named pip
  Traceback (most recent call last):
    File "/usr/lib64/python3.5/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
      subprocess.check_call(cmd)
    File "/usr/lib64/python3.5/subprocess.py", line 271, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpp7fvgp36', '--quiet', 'numpy>=1.13.3']' returned non-zero exit status 1

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib64/python3.5/site-packages/pip-20.0.2-py3.5.egg/pip/_vendor/pep517/_in_process.py", line 257, in <module>
      main()
    File "/usr/lib64/python3.5/site-packages/pip-20.0.2-py3.5.egg/pip/_vendor/pep517/_in_process.py", line 240, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/lib64/python3.5/site-packages/pip-20.0.2-py3.5.egg/pip/_vendor/pep517/_in_process.py", line 182, in build_wheel
      metadata_directory)
    File "/usr/lib64/python3.5/site-packages/setuptools/build_meta.py", line 213, in build_wheel
      wheel_directory, config_settings)
    File "/usr/lib64/python3.5/site-packages/setuptools/build_meta.py", line 198, in _build_with_temp_dir
      self.run_setup()
    File "/usr/lib64/python3.5/site-packages/setuptools/build_meta.py", line 250, in run_setup
      self).run_setup(setup_script=setup_script)
    File "/usr/lib64/python3.5/site-packages/setuptools/build_meta.py", line 143, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 540, in <module>
      setup_package()
    File "setup.py", line 536, in setup_package
      setup(**metadata)
    File "/usr/lib64/python3.5/site-packages/numpy/distutils/core.py", line 126, in setup
      dist = setup(**new_attr)
    File "/usr/lib64/python3.5/site-packages/numpy/distutils/core.py", line 169, in setup
      return old_setup(**new_attr)
    File "/usr/lib64/python3.5/site-packages/setuptools/__init__.py", line 143, in setup
      _install_setup_requires(attrs)
    File "/usr/lib64/python3.5/site-packages/setuptools/__init__.py", line 138, in _install_setup_requires
      dist.fetch_build_eggs(dist.setup_requires)
    File "/usr/lib64/python3.5/site-packages/setuptools/dist.py", line 698, in fetch_build_eggs
      replace_conflicting=True,
    File "/usr/lib64/python3.5/site-packages/pkg_resources/__init__.py", line 783, in resolve
      replace_conflicting=replace_conflicting
    File "/usr/lib64/python3.5/site-packages/pkg_resources/__init__.py", line 1066, in best_match
      return self.obtain(req, installer)
    File "/usr/lib64/python3.5/site-packages/pkg_resources/__init__.py", line 1078, in obtain
      return installer(requirement)
    File "/usr/lib64/python3.5/site-packages/setuptools/dist.py", line 754, in fetch_build_egg
      return fetch_build_egg(self, req)
    File "/usr/lib64/python3.5/site-packages/setuptools/installer.py", line 130, in fetch_build_egg
      raise DistutilsError(str(e))
  distutils.errors.DistutilsError: Command '['/usr/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpp7fvgp36', '--quiet', 'numpy>=1.13.3']' returned non-zero exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for scipy
Failed to build scipy
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly

12 个答案:

答案 0 :(得分:15)

numpy 也会出现此错误,如果您使用的是新的 M1 芯片,恐怕您必须以不同的方式安装 numpy 之类的软件包。检查this

答案 1 :(得分:7)

我在opencv-python中遇到了同样的问题。对我有用的是将pip更新为:

pip3 install --upgrade pip

注意:我在Linux上使用docker。

答案 2 :(得分:4)

直接做

pip install p5py
pip install PEP517

这将完成工作。

答案 3 :(得分:3)

我的问题不是scipy,而是xmlsec。错误消息几乎相同:

ERROR: Could not build wheels for xmlsec which use PEP 517 and cannot be installed directly

我需要这个库,因为它是python3-saml的依赖项。从文档中我读到他们首先安装了这些软件包:

sudo apt-get install libxml2-dev libxmlsec1-dev

完成此操作后,python3-saml的安装对我有用。

pip3 -V
pip 20.2.3

python -V
Python 3.8.0b3

其他库的答案可能有所不同,但是它们都需要一些软件包才能构建,因此您应该为您找到这个软件包。

答案 4 :(得分:3)

我有同样的问题。我在命令下运行后解决了这个问题

pip install --upgrade pip setuptools wheel

答案 5 :(得分:3)

我遇到了同样的问题。似乎 pip 使用 pkg-config - 如果您的主机操作系统缺少它,它将遇到此错误。我通过以下方式解决:

sudo apt-get install -y pkg-config

然后重新运行pip

答案 6 :(得分:2)

就我而言,我使用以下命令从 requirements.txt 文件进行安装:

pip install -r requirements.txt

并且收到此错误。我解决了它单独安装软件包 (pip install scipy) 并将 requirements.txt 中的 Scipy 版本替换为可用的版本。

答案 7 :(得分:1)

如果使用 Windows 操作系统,请在“开始”>“设置”>“更新和安全”>“Windows 安全”>“病毒和威胁防护”>“保护历史记录”下验证 Windows 是否将使用 Pip 安装 PyInstaller 的文件识别为潜在恶意软件并因此阻止它。为我工作。

答案 8 :(得分:1)

ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py which use PEP 517 and cannot be installed directly

我在安装 Keras 时遇到了类似的问题,使用以下步骤解决了上述问题:

  1. conda 安装 h5py

  2. pip 安装 keras

答案 9 :(得分:0)

我遇到了同样的问题,并通过使用conda安装模块解决了该问题。 在我的情况下, conda install -c conda-forge statsmodels 正常运行。

答案 10 :(得分:0)

我个人通过将位于 ~/.poetry/bin/poetry 的文件中的 > sessionInfo() R version 4.0.0 (2020-04-24) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux Matrix products: default BLAS/LAPACK: /zapps7/intel_parallel_studio_xe/2020/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] withr_2.4.1 loaded via a namespace (and not attached): [1] compiler_4.0.0 tools_4.0.0 更改为 #!/usr/bin/env python3.9 并运行 #!/usr/bin/env python3 来摆脱这个错误,显然 python3.9 得到了一些诗歌困难。

答案 11 :(得分:0)

我在尝试安装 tidyms 包时遇到了这个问题(这取决于 scipy <= 1.4.1)。

就我而言,使用 python 3.8 而不是 python 3.9“解决”了问题(至少能够安装)。