'Can't pip install scipy on M1
I can't "pip instal scipy" on my m1 mac, I get an error:
Collecting scipy
Using cached scipy-1.7.3.tar.gz (36.1 MB)
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [3280 lines of output]
Looking in indexes: https://pypi.org/simple, https://pypi.dev.project.com/pypi/, https://pypi.dev.project.com/pypi/
Ignoring numpy: markers 'python_version == "3.7" and platform_machine == "aarch64"' don't match your environment
Ignoring numpy: markers 'python_version == "3.8" and platform_machine == "aarch64"' don't match your environment
Ignoring numpy: markers 'python_version == "3.8" and (platform_machine != "arm64" or platform_system != "Darwin") and platform_python_implementation != "PyPy"' don't match your environment
Ignoring numpy: markers 'python_version == "3.9" and (platform_machine != "arm64" or platform_system != "Darwin") and platform_python_implementation != "PyPy"' don't match your environment
Ignoring numpy: markers 'python_version == "3.10" and platform_python_implementation != "PyPy"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_python_implementation == "PyPy"' don't match your environment
Ignoring numpy: markers 'python_version == "3.8" and platform_python_implementation == "PyPy"' don't match your environment
Ignoring numpy: markers 'python_version == "3.9" and platform_python_implementation == "PyPy"' don't match your environment
Ignoring numpy: markers 'python_version == "3.10" and platform_python_implementation == "PyPy"' don't match your environment
Collecting wheel<0.38.0
Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Collecting setuptools<58.0.0
Using cached setuptools-57.5.0-py3-none-any.whl (819 kB)
Collecting Cython<3.0,>=0.29.18
Using cached Cython-0.29.28-py2.py3-none-any.whl (983 kB)
Collecting pybind11<2.8.0,>=2.4.3
Using cached pybind11-2.7.1-py2.py3-none-any.whl (200 kB)
Collecting pythran<0.10.0,>=0.9.12
Using cached pythran-0.9.12.post1-py3-none-any.whl (4.3 MB)
Collecting numpy==1.16.5
Using cached numpy-1.16.5.zip (5.1 MB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting ply>=3.4
Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Collecting gast~=0.5.0
Using cached gast-0.5.3-py3-none-any.whl (19 kB)
Collecting beniget~=0.4.0
Using cached beniget-0.4.1-py3-none-any.whl (9.4 kB)
Building wheels for collected packages: numpy
Building wheel for numpy (setup.py): started
Building wheel for numpy (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [2943 lines of output]
Running from numpy source directory.
blas_opt_info:
blas_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/Users/danieljohnson/Documents/code/project/venv/lib', '/usr/local/lib', '/usr/lib']
NOT AVAILABLE
blis_info:
customize UnixCCompiler
libraries blis not found in ['/Users/danieljohnson/Documents/code/project/venv/lib', '/usr/local/lib', '/usr/lib']
NOT AVAILABLE
openblas_info:
customize UnixCCompiler
customize UnixCCompiler
libraries openblas not found in ['/Users/danieljohnson/Documents/code/project/venv/lib', '/usr/local/lib', '/usr/lib']
NOT AVAILABLE
... the end of the error is:
error: Command "clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Users/danieljohnson/Documents/code/project/venv/lib/python3.7/site-packages/numpy/core/include -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -Inumpy/core/include -Ibuild/src.macosx-12.3-arm64-3.7/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/danieljohnson/Documents/code/project/venv/include -I/Users/danieljohnson/.pyenv/versions/3.7.13/include/python3.7m -Ibuild/src.macosx-12.3-arm64-3.7/numpy/core/src/common -Ibuild/src.macosx-12.3-arm64-3.7/numpy/core/src/npymath -Ibuild/src.macosx-12.3-arm64-3.7/numpy/core/src/common -Ibuild/src.macosx-12.3-arm64-3.7/numpy/core/src/npymath -c build/src.macosx-12.3-arm64-3.7/numpy/core/src/multiarray/_multiarray_tests.c -o build/temp.macosx-12.3-arm64-3.7/build/src.macosx-12.3-arm64-3.7/numpy/core/src/multiarray/_multiarray_tests.o -MMD -MF build/temp.macosx-12.3-arm64-3.7/build/src.macosx-12.3-arm64-3.7/numpy/core/src/multiarray/_multiarray_tests.o.d" failed with exit status 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> numpy
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I've tried pip and pip3 uninstalling numpy, using older versions, installing scypi with --no-deps.
I can import numpy in a python console.
A "pip show numpy" displays:
Name: numpy
Version: 1.21.6
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location: /Users/danieljohnson/Documents/code/project/venv/lib/python3.7/site-packages
Requires:
Required-by: pandas
I'm not sure what to try. I think it either has something to do with the m1 architecture or the install not being able to find numpy for some reason.
Solution 1:[1]
I would suggest you to use conda for managing your Python resources on your Mac M1 machine, unless you have a specific reason to stick with pip or pip3.
Below are the key steps that might help you to quickly install scipy package:
Install
minicondaon your Mac: please follow step 1 to 6 on this page under the title Installing on MacOS. Don't worry about subpoint, Anaconda Installer for MacOS, in step 1 on the link attached above.Create a new environment for your work purpose. It's recommended to not install packages in
baseenvironment ofconda, and that's why I am suggesting for creating new environment. Please follow the sections, Managing conda and Managing environments, on this page.Set
conda-forgeasconda's highest priority channel. This meanscondawill always check if Python packages you want to install are available viaconda-forgeor not. To do this, please type following lines of code in the terminal:conda config --add channels conda-forge conda config --set channel_priority strictYou can read about
conda-forgehere.Finally, type
conda install scipyin the terminal by activating your non-basecondaenvironment. This should installscipyalong with its dependencies with your permission on your machine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DharmanBot |
