8000 Cannot pip install numpy on mac M1 · Issue #18195 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Cannot pip install numpy on mac M1 #18195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stewjb opened this issue Jan 20, 2021 · 11 comments
Closed

Cannot pip install numpy on mac M1 #18195

stewjb opened this issue Jan 20, 2021 · 11 comments

Comments

@stewjb
Copy link
stewjb commented Jan 20, 2021

Cannot pip install numpy.

Reproducing code example:

python -m pip install numpy

Error message:

Collecting numpy
Using cached numpy-1.19.5.zip (7.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /Users/jeffstewart/maroon-bells/venv/bin/python /Users/jeffstewart/maroon-bells/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/tmpvko_1s0y
cwd: /private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c
Complete output (185 lines):
Running from numpy source directory.
setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
run_build = parse_setuppy_commands()
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_philox.pyx
Processing numpy/random/_bounded_integers.pyx.in
Processing numpy/random/_sfc64.pyx
Processing numpy/random/_mt19937.pyx
Processing numpy/random/bit_generator.pyx
Processing numpy/random/mtrand.pyx
Processing numpy/random/_generator.pyx
Processing numpy/random/_pcg64.pyx
Processing numpy/random/_common.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
NOT AVAILABLE

blis_info:
  libraries blis not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

openblas_info:
  libraries openblas not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

atlas_3_10_blas_threads_info:
Setting PTATLAS=ATLAS
  libraries tatlas not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

atlas_3_10_blas_info:
  libraries satlas not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

atlas_blas_info:
  libraries f77blas,cblas,atlas not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

accelerate_info:
  libraries accelerate not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
Library accelerate was not found. Ignoring
  libraries veclib not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
Library veclib was not found. Ignoring
  FOUND:
    extra_compile_args = ['-faltivec', '-I/System/Library/Frameworks/vecLib.framework/Headers']
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]

  FOUND:
    extra_compile_args = ['-faltivec', '-I/System/Library/Frameworks/vecLib.framework/Headers']
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]

non-existing path in 'numpy/distutils': 'site.cfg'
lapack_opt_info:
lapack_mkl_info:
  libraries mkl_rt not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

openblas_lapack_info:
  libraries openblas not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

openblas_clapack_info:
  libraries openblas,lapack not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

flame_info:
  libraries flame not found in ['/Users/jeffstewart/maroon-bells/venv/lib', '/usr/local/lib', '/usr/lib']
  NOT AVAILABLE

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
  libraries lapack_atlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries tatlas,tatlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries tatlas,tatlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/lib
  libraries tatlas,tatlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
  NOT AVAILABLE

atlas_3_10_info:
  libraries lapack_atlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries satlas,satlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries satlas,satlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/lib
  libraries satlas,satlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_3_10_info'>
  NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
  libraries lapack_atlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries ptf77blas,ptcblas,atlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_threads_info'>
  NOT AVAILABLE

atlas_info:
  libraries lapack_atlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries f77blas,cblas,atlas not found in /Users/jeffstewart/maroon-bells/venv/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries f77blas,cblas,atlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/lib
  libraries f77blas,cblas,atlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_info'>
  NOT AVAILABLE

  FOUND:
    extra_compile_args = ['-faltivec', '-I/System/Library/Frameworks/vecLib.framework/Headers']
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]

/Users/jeffstewart/.pyenv/versions/3.9.1/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
  warnings.warn(msg)
running dist_info
running build_src
build_src
building py_modules sources
creating build
creating build/src.macosx-11.1-arm64-3.9
creating build/src.macosx-11.1-arm64-3.9/numpy
creating build/src.macosx-11.1-arm64-3.9/numpy/distutils
building library "npymath" sources
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
  File "/Users/jeffstewart/maroon-bells/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
    main()
  File "/Users/jeffstewart/maroon-bells/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/jeffstewart/maroon-bells/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
    return hook(metadata_directory, config_settings)
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-build-env-98_m8bsv/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 157, in prepare_metadata_for_build_wheel
    self.run_setup()
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-build-env-98_m8bsv/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 248, in run_setup
    super(_BuildMetaLegacyBackend,
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-build-env-98_m8bsv/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 142, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 508, in <module>
    setup_package()
  File "setup.py", line 500, in setup_package
    setup(**metadata)
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-build-env-98_m8bsv/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 165, in setup
    return distutils.core.setup(**attrs)
  File "/Users/jeffstewart/.pyenv/versions/3.9.1/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/jeffstewart/.pyenv/versions/3.9.1/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Users/jeffstewart/.pyenv/versions/3.9.1/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-build-env-98_m8bsv/overlay/lib/python3.9/site-packages/setuptools/command/dist_info.py", line 31, in run
    egg_info.run()
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c/numpy/distutils/command/egg_info.py", line 24, in run
    self.run_command("build_src")
  File "/Users/jeffstewart/.pyenv/versions/3.9.1/lib/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/Users/jeffstewart/.pyenv/versions/3.9.1/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c/numpy/distutils/command/build_src.py", line 144, in run
    self.build_sources()
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c/numpy/distutils/command/build_src.py", line 155, in build_sources
    self.build_library_sources(*libname_info)
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c/numpy/distutils/command/build_src.py", line 288, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "/private/var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/pip-install-cgcf8n0u/numpy_f7d15ee151114f0aa52d02ed62f75e3c/numpy/distutils/command/build_src.py", line 378, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setu
8000
p.py", line 663, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
----------------------------------------

ERROR: Command errored out with exit status 1: /Users/jeffstewart/maroon-bells/venv/bin/python /Users/jeffstewart/maroon-bells/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/6q/jk0p94b12x713m1c02tyt1fc0000gn/T/tmpvko_1s0y Check the logs for full command output.

NumPy/Python version information:

Numpy version 1.19.5
Python version 3.9.1
macOS Big Sur 11.1 (Apple Silicon)

@picn0113
Copy link

RuntimeError: Broken toolchain: cannot link a simple C program

@charris
Copy link
Member
charris commented Jan 21, 2021

Why are you installing from source?

@stewjb
Copy link
Author
stewjb commented Jan 21, 2021

Why are you installing from source?

Sorry I might not understand this 100%, but we have a requirements.txt file in my repository with numpy being in it. When i run python -m pip install -r requirements.txt numpy fails. Is there a better way to install dependencies?

@charris
Copy link
Member
charris commented Jan 21, 2021

Pip is using a cached zip file, e.g., a file of source code. You can force it to use binary wheels

python -mpip install --only-binary numpy

But the question is where the zip file came from, and if you are on a supported platform. What hardware?

@stewjb
Copy link
Author
stewjb commented Jan 22, 2021

Pip is using a cached zip file, e.g., a file of source code. You can force it to use binary wheels

python -mpip install --only-binary numpy

But the question is where the zip file came from, and if you are on a supported platform. What hardware?

It can't find the binary it seems. When i use the command python -m pip install --only-binary=:all: numpy==1.19.5 i get this error:
ERROR: Could not find a version that satisfies the requirement numpy==1.19.5 ERROR: No matching distribution found for numpy==1.19.5

Here are my specs:
Numpy version 1.19.5
Python version 3.9.1
pip version 20.3.3
wheel version 0.36.2
macOS Big Sur 11.1 (Apple Silicon/M1)
16gb ram

@mattip mattip changed the title Cannot pip install numpy with pip 20.3.3 Cannot pip install numpy on mac M1 Jan 22, 2021
@mattip
Copy link
Member
mattip commented Jan 22, 2021

Duplicate of #18160, #18143. You should have led with the data point that you are using the new Apple Silicon M1 hardware. We don't currently support that hardware until we can run CI on it. You may have more luck with conda, I think they have binary packages for M1. In the meantime you can use the x86_64 Rosetta emulation.

@stewjb stewjb closed this as completed Jan 26, 2021
@sbassi
Copy link
sbassi commented Jan 22, 2022

One year later still can't compile Numpy on M1?

I got this:

Collecting matplotlib==3.4.2
  Downloading matplotlib-3.4.2.tar.gz (37.3 MB)
     |████████████████████████████████| 37.3 MB 907 kB/s 
    ERROR: Command errored out with exit status 1:
     command: /Users/sb/venvs/loambioweb/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/qz/kww4c4nx2q71dzf_gzmp3bkc0000gn/T/pip-install-d40pdmke/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/qz/kww4c4nx2q71dzf_gzmp3bkc0000gn/T/pip-install-d40pdmke/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/qz/kww4c4nx2q71dzf_gzmp3bkc0000gn/T/pip-pip-egg-info-b8dja3m9
         cwd: /private/var/folders/qz/kww4c4nx2q71dzf_gzmp3bkc0000gn/T/pip-install-d40pdmke/matplotlib/
    Complete output (1350 lines):
      ERROR: Command errored out with exit status 1:
       command: /Users/sb/venvs/loambioweb/bin/python3 /Users/sb/venvs/loambioweb/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/qz/kww4c4nx2q71dzf_gzmp3bkc0000gn/T/tmpdg8gpnty
           cwd: /private/var/folders/qz/kww4c4nx2q71dzf_gzmp3bkc0000gn/T/pip-wheel-zucxmb5w/numpy
      Complete output (1302 lines):
      Processing numpy/random/_bounded_integers.pxd.in
      Processing numpy/random/_philox.pyx
      Processing numpy/random/_bounded_integers.pyx.in
      Processing numpy/random/_sfc64.pyx
      Processing numpy/random/_mt19937.pyx
      Processing numpy/random/bit_generator.pyx
      Processing numpy/random/mtrand.pyx
      Processing numpy/random/_generator.pyx
      Processing numpy/random/_pcg64.pyx
      Processing numpy/random/_common.pyx
      Cythonizing sources
      INFO: blas_opt_info:
      INFO: blas_armpl_info:
      INFO: customize UnixCCompiler
      INFO:   libraries armpl_lp64_mp not found in ['/Users/sb/venvs/loambioweb/lib', '/usr/lib']
      INFO:   NOT AVAILABLE
      INFO:
      INFO: blas_mkl_info:
      INFO:   libraries mkl_rt not found in ['/Users/sb/venvs/loambioweb/lib', '/usr/lib']
      INFO:   NOT AVAILABLE
      INFO:
      INFO: blis_info:
      INFO:   libraries blis not found in ['/Users/sb/venvs/loambioweb/lib', '/usr/lib']
      INFO:   NOT AVAILABLE
      INFO:
      INFO: openblas_info:
      INFO:   libraries openblas not found in ['/Users/sb/venvs/loambioweb/lib', '/usr/lib']
      INFO:   NOT AVAILABLE
...

@JoshuaSchlichting
Copy link
JoshuaSchlichting commented Apr 11, 2022

If any future M1 users come across this, but their error was related to installing in docker, they can try adding the following argument to your docker build command: --platform linux/amd64

This resolved my issue with this error when using Docker.

@komal-sharan
Copy link

need help, same error

@mattip
Copy link
Member
mattip commented Jul 13, 2022

@komal-sharan this issue is closed and we now have wheels for M1. Please open a new issue with full information about

  • where you got python
  • what command you are running
  • what is the exact error. Please copy paste the text (not a screen capture of the image) of the traceback.

@petervanderdoes
Copy link

For Ubuntu install the needed packages:

sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev gfortran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants
0