Build from source error: cmake could not find python3

Hi, I’m new to Netgen and currently struggling to install the package. I was trying to build the package from source by following the NGS-Py documentation page “Build on Mac OS X”. An error occurred in the step “cmake $NGROOT/ngsolve-src”, as seen below (highlighted).

I do have python3 installed as “which python3” gives “/usr/bin/python3” and python3 version is 3.8.2. What’s the problem and how to fix this issue? I plan to use Netgen for my projects and hope to get on going as soon as I can. Thanks!

Configure Netgen from submodule…
Checking for write permissions in install directory…
> CMake Error at /Applications/CMake.app/Contents/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
> Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Development.Module)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
/Applications/CMake.app/Contents/share/cmake-3.30/Modules/FindPython/Support.cmake:4002 (find_package_handle_standard_args)
/Applications/CMake.app/Contents/share/cmake-3.30/Modules/FindPython3.cmake:596 (include)
CMakeLists.txt:89 (find_package)

– Configuring incomplete, errors occurred!
– Configuring done (2.0s)
– Generating done (0.0s)
– Build files have been written to: /Applications/NGsolve/ngsolve-build

do you have python3-dev installed as well ?

Thanks for the quick reply. I tried different ways to see if it is installed. First I went to “/usr/bin” and tried “ls python*”, which gives:

python, python2.7-config, python-config, python3, python2, pythonw, python2.7, pythonw2.7

Then “brew info python3” gives:

==> Caveats
Python has been installed as
/opt/homebrew/bin/python3

Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been installed into
/opt/homebrew/opt/python@3.12/libexec/bin

At this moment I’m not sure if python3-dev is installed. I did some online search and one thread says it’s included in the package installed from brew. Do you have any suggestions?

On Mac, I am using Python directly from https://www.python.org.

I am using the latest version 3.12.4. python3 is installed in /Library/Frameworks/Python.framework/Versions/3.12/bin, which I have put into my path.

Joachim

Thanks, it resolved the issue after I downloaded Python v3.12. Another missing part “opencascade” can be resolved with “cmake $NGROOT/ngsolve-src -DBUILD_OCC=ON” and this step finally went through. I was happy to finally “make” but this time consuming step gives the following error (besides tons of warnings) after

[ 95%] Performing build step for ‘netgen’
Found Git: /usr/bin/git (found version “2.24.3 (Apple Git-128)”)
[ 0%] Built target ng_generate_version_file

error message:

[ 14%] Building CXX object CMakeFiles/nglib.dir/libsrc/general/gzstream.cpp.o
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/general/gzstream.cpp:30:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/include/myadt.hpp:1:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/include/../general/myadt.hpp:16:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/general/../include/mydefs.hpp:14:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/core/ngcore.hpp:16:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/core/simd.hpp:32:
/Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/core/simd_arm64.hpp:162:16: error: 
      use of undeclared identifier 'vcmlaq_f64'; did you mean
      'vmlaq_f64'?
    auto tmp = vcmlaq_f64(c.Data(), a.Data(), b.Data())...
               ^~~~~~~~~~
               vmlaq_f64
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/arm_neon.h:48728:18: note: 
      'vmlaq_f64' declared here
__ai float64x2_t vmlaq_f64(float64x2_t __p0, float64x2_t ...
                 ^
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/general/gzstream.cpp:30:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/include/myadt.hpp:1:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/include/../general/myadt.hpp:16:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/general/../include/mydefs.hpp:14:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/core/ngcore.hpp:16:
In file included from /Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/core/simd.hpp:32:
/Applications/NGsolve/ngsolve-src/external_dependencies/netgen/libsrc/core/simd_arm64.hpp:163:9: error: 
      use of undeclared identifier 'vcmlaq_rot90_f64'
    c = vcmlaq_rot90_f64(tmp, a.Data(), b.Data());    // ...
        ^
2 errors generated.
make[8]: *** [CMakeFiles/nglib.dir/libsrc/general/gzstream.cpp.o] Error 1
make[7]: *** [CMakeFiles/nglib.dir/all] Error 2
make[6]: *** [all] Error 2
make[5]: *** [dependencies/src/netgen-stamp/netgen-build] Error 2
make[4]: *** [CMakeFiles/netgen.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [dependencies/src/netgen_project-stamp/netgen_project-build] Error 2
make[1]: *** [CMakeFiles/netgen_project.dir/all] Error 2
make: *** [all] Error 2

I have no idea. My laptop is M1 chip btw, not sure if this causes the problem with simd.

that’s an issue of the compiler / runtime. Looks like you have Apple-clang 12 ?
With Apple-clang 15 it is definitely working, for M1

> clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix

Yes, you are absolutely right!

So I just downloaded clang-15 through MacPorts. I can try to direct clang to the new mp-clang-15 by sudo port select --set clang mp-clang-15, but I’m not sure this remedy is recommended. Or, is there a better option to move forward? Glad to know.