Dennis-van-Gils / DvG_Arduino_lock-in_amp

A fully fledged lock-in amplifier running at 25 kHz sampling rate @ 12-bit on an Adafruit M4 microprocessor board with an extensive Python graphical user interface showing real-time signals, interactive filter design and real-time power spectra.
MIT License
22 stars 6 forks source link

Not supported by apple silicon M3 conda distributions #47

Closed erickmartinez closed 5 months ago

erickmartinez commented 5 months ago

I tried installing the requirements.txt but pip complained that mkl is not available. I commented the 'mkl' line on requirements.txt and proceeded:

pip
ipython
# mkl  <========
psutil
pyserial  ~= 3.5

but the script failed to instal pyfftw:

Building wheels for collected packages: pyfftw, PyQt5-sip
  Building wheel for pyfftw (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pyfftw (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [41 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.0-arm64-3.8
      creating build/lib.macosx-11.0-arm64-3.8/pyfftw
      copying pyfftw/config.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw
      copying pyfftw/_version.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw
      copying pyfftw/__init__.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw
      creating build/lib.macosx-11.0-arm64-3.8/pyfftw/builders
      copying pyfftw/builders/builders.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/builders
      copying pyfftw/builders/__init__.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/builders
      copying pyfftw/builders/_utils.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/builders
      creating build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/cache.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/__init__.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/scipy_fft.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/dask_fft.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/numpy_fft.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/scipy_fftpack.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      copying pyfftw/interfaces/_utils.py -> build/lib.macosx-11.0-arm64-3.8/pyfftw/interfaces
      UPDATING build/lib.macosx-11.0-arm64-3.8/pyfftw/_version.py
      set build/lib.macosx-11.0-arm64-3.8/pyfftw/_version.py to '0.13.1'
      running build_ext
      DEBUG:__main__:Link FFTW dynamically
      DEBUG:__main__:Compiler include_dirs: ['/Users/erickmartinez/anaconda3/envs/lia/include/python3.8']
      DEBUG:__main__:3.8.10 | packaged by conda-forge | (default, Sep 13 2021, 21:14:52)
      [Clang 11.1.0 ]
      DEBUG:__main__:Sniffer include_dirs: ['/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-install-ehsq7wc0/pyfftw_eccb08eed9964fc98b6ab7187e04ac99/include', '/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-install-ehsq7wc0/pyfftw_eccb08eed9964fc98b6ab7187e04ac99/pyfftw', '/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-build-env-jy26bx7y/overlay/lib/python3.8/site-packages/numpy/core/include', '/Users/erickmartinez/anaconda3/envs/lia/include']
      DEBUG:__main__:objects: []
      DEBUG:__main__:libraries: []
      DEBUG:__main__:include dirs: ['/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-install-ehsq7wc0/pyfftw_eccb08eed9964fc98b6ab7187e04ac99/include', '/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-install-ehsq7wc0/pyfftw_eccb08eed9964fc98b6ab7187e04ac99/pyfftw', '/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-build-env-jy26bx7y/overlay/lib/python3.8/site-packages/numpy/core/include', '/Users/erickmartinez/anaconda3/envs/lia/include']
      /var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pyfftw-9uhqjrgx/None.c:1:10: fatal error: 'fftw3.h' file not found
      #include <fftw3.h>
               ^~~~~~~~~
      1 error generated.
      WARNING:__main__:Compilation error: command '/usr/bin/gcc' failed with exit code 1
      DEBUG:__main__:gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/erickmartinez/anaconda3/envs/lia/include -arch arm64 -I/Users/erickmartinez/anaconda3/envs/lia/include -arch arm64 -I/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-install-ehsq7wc0/pyfftw_eccb08eed9964fc98b6ab7187e04ac99/include -I/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-install-ehsq7wc0/pyfftw_eccb08eed9964fc98b6ab7187e04ac99/pyfftw -I/private/var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pip-build-env-jy26bx7y/overlay/lib/python3.8/site-packages/numpy/core/include -I/Users/erickmartinez/anaconda3/envs/lia/include -I/Users/erickmartinez/anaconda3/envs/lia/include/python3.8 -c /var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pyfftw-9uhqjrgx/None.c -o /var/folders/zv/mhnhzlt95zv5c8fqm65sykmw0000gn/T/pyfftw-9uhqjrgx/None.o

      DEBUG:__main__:Checking with includes ['fftw3.h']...no
      error: Could not find the FFTW header 'fftw3.h'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyfftw
  Building wheel for PyQt5-sip (pyproject.toml) ... done
  Created wheel for PyQt5-sip: filename=PyQt5_sip-12.13.0-cp38-cp38-macosx_11_0_arm64.whl size=79592 sha256=ba4d613bd71a360a2d6abc3a6d303639f9c4f926305eba696c51b8150b631d09
  Stored in directory: /Users/erickmartinez/Library/Caches/pip/wheels/7f/3f/55/593da8d20b5c2810baf2a81c8ae78449b348f09c83111c51a3
Successfully built PyQt5-sip
Failed to build pyfftw
ERROR: Could not build wheels for pyfftw, which is required to install pyproject.toml-based projects

I think fftw can be installed via conda:

https://github.com/pyFFTW/pyFFTW/issues/316#issuecomment-916199317

but I am not sure if you need mkl.

erickmartinez commented 5 months ago

Installing pyFFTW from conda-forge resolved my issue, and I was able to run the code.

Comment the mkl line in requirements.txt and run

conda install -c conda-forge pyfftw

before running

pip install requirements.txt

I did not install mkl libraries, but I am still able to run a functional version of the code on my Silicon M3 laptop. I am not sure if there are issues related to lack of mkl libraries.

Dennis-van-Gils commented 5 months ago

Thanks for your efforts in resolving the mkl and pyfftw installation issues you had on your Silicon M3 PC and clearly communicating them.

The mkl package is not mandatory, but will allegedly speed up numpy calculations if you have an Intel chipset. I have removed it from the requirements.txt to provide a wider cross-platform support.

The pyfftw library is essential. Windows PCs should have no issues installing this via pip or pip3. And I tested this with several macOS an Linux PCs as well. But there are way more OSes and chipsets than I can test for, so it's not surprising to find out pyfftw did not install out-of-the-box for your case. Glad to read you found conda to have an installation procedure ready for your system.