jdtuck / fdasrsf_python

elastic fda python code
http://research.tetonedge.net
BSD 3-Clause "New" or "Revised" License
51 stars 18 forks source link

macos install error: Could not build wheels for fdasrsf #51

Closed 0todd0000 closed 5 months ago

0todd0000 commented 5 months ago

Hello Dr. Tucker, I have successfully installed fdasrsf using pip on one Windows and one Mac machine using mkl-devel as I mentioned in Issue 47 . However, I am receiving installation errors on a different Mac and I cannot solve this installation problem so am writing to request help. Here are the details:

Versions:

The first error I encounter occurs because MKL and other libraries can't be found:

...
        File "/private/var/folders/0_/12n443nj561fm5fbvvz6clxh0000gn/T/pip-build-env-7ai96xub/overlay/lib/python3.10/site-packages/findblas/__init__.py", line 1048, in find_blas
          raise ValueError(err_msg)
      ValueError: Could not locate MKL, OpenBLAS, BLIS, ATLAS or GSL libraries - you'll need to manually modify setup.py to add BLAS path.

  ERROR: Failed building wheel for fdasrsf
Failed to build fdasrsf
ERROR: Could not build wheels for fdasrsf, which is required to install pyproject.toml-based projects

I can solve this problem by installing MKL:

pip install mkl

However, another error occurs when compiling DynamicProgrammingQ2.c because various header files cannot be found:

      creating build/temp.macosx-10.9-universal2-cpython-310
      creating build/temp.macosx-10.9-universal2-cpython-310/src
      compile options: '-DHAS_MKL -DNO_CBLAS_HEADER -I/private/var/folders/0_/12n443nj561fm5fbvvz6clxh0000gn/T/pip-build-env-cnpng7nk/overlay/lib/python3.10/site-packages/numpy/core/include -I/private/var/folders/0_/12n443nj561fm5fbvvz6clxh0000gn/T/pip-build-env-cnpng7nk/overlay/lib/python3.10/site-packages/findblas/ -I/Users/todd/envs/jiku/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c'
      clang: src/DynamicProgrammingQ2.c
      clang: src/dp_grid.c
      clang: src/dp_nbhd.c
      clang: src/optimum_reparamN2.c
      src/dp_grid.c:1:10: fatal error: 'stdio.h' file not found
      #include <stdio.h>
               ^~~~~~~~~
      src/DynamicProgrammingQ2.c:1:10: fatal error: 'math.h' file not found
      #include <math.h>
               ^~~~~~~~
      1 error generated.
      1 error generated.
      src/dp_nbhd.c:3:10: fatal error: 'stdio.h' file not found
      #include <stdio.h>
               ^~~~~~~~~
      1 error generated.
      In file included from src/optimum_reparamN2.c:60:
      /Library/Frameworks/Python.framework/Versions/3.10/include/python3.10/Python.h:25:10: fatal error: 'stdio.h' file not found
      #include <stdio.h>
               ^~~~~~~~~
      1 error generated.
      error: Command "clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DHAS_MKL -DNO_CBLAS_HEADER -I/private/var/folders/0_/12n443nj561fm5fbvvz6clxh0000gn/T/pip-build-env-cnpng7nk/overlay/lib/python3.10/site-packages/numpy/core/include -I/private/var/folders/0_/12n443nj561fm5fbvvz6clxh0000gn/T/pip-build-env-cnpng7nk/overlay/lib/python3.10/site-packages/findblas/ -I/Users/todd/envs/jiku/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/DynamicProgrammingQ2.c -o build/temp.macosx-10.9-universal2-cpython-310/src/DynamicProgrammingQ2.o" failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for fdasrsf
Failed to build fdasrsf
ERROR: Could not build wheels for fdasrsf, which is required to install pyproject.toml-based projects

I can solve this problem by setting the SDK as described here

export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

but then a third error is generated that I cannot solve:

     clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-cpython-310/src/DynamicProgrammingQ2.o build/temp.macosx-10.9-universal2-cpython-310/src/dp_grid.o build/temp.macosx-10.9-universal2-cpython-310/src/dp_nbhd.o build/temp.macosx-10.9-universal2-cpython-310/src/optimum_reparamN2.o -o build/lib.macosx-10.9-universal2-cpython-310/optimum_reparamN2.cpython-310-darwin.so -L/Users/todd/envs/jiku/lib -lmkl_rt.2 -Wl,-rpath,/Users/todd/envs/jiku/lib
      ld: warning: ignoring file /Users/todd/envs/jiku/lib/libmkl_rt.2.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/anaconda3/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a, missing required architecture arm64 in file /Applications/anaconda3/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a (3 slices)
      ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture arm64
      clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
      error: Command "clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-cpython-310/src/DynamicProgrammingQ2.o build/temp.macosx-10.9-universal2-cpython-310/src/dp_grid.o build/temp.macosx-10.9-universal2-cpython-310/src/dp_nbhd.o build/temp.macosx-10.9-universal2-cpython-310/src/optimum_reparamN2.o -o build/lib.macosx-10.9-universal2-cpython-310/optimum_reparamN2.cpython-310-darwin.so -L/Users/todd/envs/jiku/lib -lmkl_rt.2 -Wl,-rpath,/Users/todd/envs/jiku/lib" failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for fdasrsf
Failed to build fdasrsf
ERROR: Could not build wheels for fdasrsf, which is required to install pyproject.toml-based projects

To check in more detail can I please request specific versions of the requirements, including the Python version?

jdtuck commented 5 months ago

I need more info on machine, version, what version of XCode, etc. Also it looks like you are mixing anaconda with base python on the mac. You cannot mix environments and probably have anaconda somewhere on your path.

0todd0000 commented 5 months ago

Thank you very much for your prompt reply! Easy part first: versions:

Second: your question actually helped me to solve the problem! I had attempted to isolate the environment using venv, but I see now that Anaconda snuck some paths into my .zprofile, and these were polluting the venv paths. I removed those Anaconda paths from my .zprofile and consequently the venv and this has solved my problem. I can now install fdasrsf via pip using the versions above.

Thank you!!