59
votes

I'm trying to install scipy via pip on my 64 bit ARMV8 board. I have already installed openblas which is required by scipy. So, no issues with that. When i gave pip3 install scipy --trusted-host pypi.org --trusted-host files.pythonhosted.org , I got the error Failed building wheel for scipy . I have pip3 and pip3.5 in my /usr/bin and the rest of the pip is in /usr/lib64/python3.5/site-packages.So basically, I also have pip.

I also tried to install scipy with --no-binary option, which was one of the answers on net. But, it gave me the same error. Below's the error that i got.

ERROR:

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
11
/usr/bin/python3 --version? /usr/bin/python3 -m pip --version? - phd
@phd: /usr/bin/python3 --version is Python 3.5.3 and /usr/bin/python3 -m pip --version says no module named pip. - Sourabrt
You need to install pip - phd
@phd: I already have pip installed. /usr/bin/pip3 --version gives pip 20.0.2 from /usr/lib64/python3.5/site-packages/pip-20.0.2-py3.5.egg/pip (python 3.5) - Sourabrt
"/usr/bin/python3 -m pip --version says no module named pip." means you don't have pip installed or /usr/bin/python3 doesn't know where to find it. /usr/bin/python3 -c "import sys; print(sys.path)" — is /usr/lib64/python3.5/site-packages in the list? - phd

11 Answers

34
votes

I had the same issue with opencv-python. What worked for me was updating pip as:

pip3 install --upgrade pip

Note: I am using docker on Linux.

24
votes

I had the same issue. I resolved this issue after run below command

pip install --upgrade pip setuptools wheel
17
votes

My problem was not with scipy, but with xmlsec. The error message was almost the same:

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

I needed this library, because it was dependency for python3-saml. From the documentation I read that they first install these packages:

sudo apt-get install libxml2-dev libxmlsec1-dev

After doing this the installation of python3-saml worked for me.

pip3 -V
pip 20.2.3

python -V
Python 3.8.0b3

Probably the answer for other libraries is different, but they all need some package in order to be build, and you should find what is this package for you.

15
votes

This error also comes for numpy and if you are using the new M1 chip, I am afraid you have to install packages like numpy differently. Check this out.

5
votes

directly do

pip install p5py
pip install PEP517

this will do the work.

3
votes

I faced the same problem. Seems that pip uses the pkg-config - if this is missing from your host OS it will run into this error. I resolved by:

sudo apt-get install -y pkg-config

Then re-run pip

2
votes

In my case I was installing from a requirements.txt file with the command:

pip install -r requirements.txt

And was getting this error. I solved it installing the package individually (pip install scipy) and replacing the version of Scipy I had in requirements.txt with the one that worked.

1
votes

If using Windows OS, verify under Start > Settings > Update & Security > Windows Security > Virus & threat protection > Protection History if Windows is identifying the file for installing PyInstaller with Pip as potential malware and thus blocking it. Worked for me.

1
votes

Personally I get rid of this error by changing the #!/usr/bin/env python3.9 to #!/usr/bin/env python3 in the file located in ~/.poetry/bin/poetry and running pip3 install --upgrade pip setuptools wheel apparently python3.9 got some difficulties with poetry.

1
votes
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

I had a similar issue while installing Keras, resolved above issue using below steps:

  1. conda install h5py

  2. pip install keras

0
votes

I had the same issue and solved it by installing the module using conda. In my case conda install -c conda-forge statsmodels worked without error.