How to install SciPy and Numpy on Windows on ARM64

1.4k Views Asked by At

I need numpy and scipy to perform some signal analysis. Has anyone succeeded in doing this? (I am interested in running it natively, not via virtualenv). My ultimate goal is to build an exe from the python script that uses numpy and scipy that can be run in WinPE for tests.

I have successfully installed python 3.11.2 and am able to get to numpy installation which also fails at this.

  INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
  running build_src
  INFO: build_src
  INFO: building py_modules sources
  creating build
  creating build\src.win-arm64-3.11
  creating build\src.win-arm64-3.11\numpy
  creating build\src.win-arm64-3.11\numpy\distutils
  INFO: building library "npymath" sources
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for numpy Failed to build numpy

3

There are 3 best solutions below

0
On

Numpy and Scipy don't provide pre-built binary wheels for Windows Arm64 yet and need to be built from the source during installation. You will need to install Visual Studio 2019 with C/C++ toolchains.

0
On

This might be because you need Microsoft Visual C++ 14.0 or greater installed to build numpy you can download the latest build tool here https://visualstudio.microsoft.com/visual-cpp-build-tools/

then you should be able to install numpy and SciPy with this in your command prompt

pip install numpy scipy
0
On

This will be an interesting exercise. If you have experience in building software go straight ahead. If you're new to building packages, then you might need a different way.

To build windows+ARM native packages of numpy and scipy:

  • Not only will you need a C/C++ compiler, you will also need a Fortran compiler. I am not sure if gfortran is available for WinARM (that's what we typically use to build scipy wheels). ifort is another compiler to look into. scipy wheels are made with gcc/g++/gfortran.
  • You will need to download + build a BLAS library from source. The scipy/numpy projects typically use OpenBLAS.
  • You will need to build + install packages for all the build time dependencies. i.e. Cython, pybind11, (pythran), meson, meson-python, ninja. Some of those may have dependencies of their own. A couple of those have OS/arch independent wheels, but not all.
  • Once you've built all of those you'll build numpy, then scipy.

This is a large task, and even then some of the packages may have bugs that are exposed when you try and do Windows + ARM.

Can you use an emulated python environment? e.g. does Windows+ARM permit x86_64 python interpreters to run? Alternatively could you use WSL to run a Python interpreter?