Installation issue M1 macOS

Hi, I tried to install ngsxfem on my M1 macOS 12.4 by first installing ngsolve from source, following Build on Mac OS X. — NGS-Py 6.2.2402 documentation. I did exactly as the steps said, except in my python path I have python3.10 instead of python3.8. I got an error with tkinter, but if I comment “import netgen.gui” I can run the poisson.ipynb file.

Next, I want to install ngsxfem from source by following ngsxfem/INSTALLATION.md at master · ngsxfem/ngsxfem · GitHub “Installation steps on MacOS”.

Since I have the Netgen.app successfully installed I put INSTLOCATION to /Applications/Netgen.app as recommended. However, when I run

cmake \
 -DCMAKE_INSTALL_PREFIX=/Applications/Netgen.app\
 -DNGSolve_DIR=/Applications/Netgen.app/Contents/Resources/CMake \
 -DBUILD_NGSOLVE=OFF \
 ${BASEDIR}/src-xfem

I get the following error message:

"
– Found PythonInterp: /opt/homebrew/bin/python3 (found suitable version “3.12.2”, minimum required is “3”)
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
(Required is at least version “3”)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/Applications/CMake.app/Contents/share/cmake-3.21/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:67 (find_package)
"

It seems like it doesn’t find the correct python paths, but when I run “echo $PYTHONPATH” I get “:/Applications/Netgen.app/Contents/Resources/lib/python3.10/site-packages:.”

Does anyone know what I am doing wrong?

Hi,

Try to set -DPython3_EXECUTABLE=path_to_your_python_exe when calling CMake. This should let CMake choose the correct python 3 version.

(Although there seem to be problems in cmake specify specific python3 version when multiple versions are installed (prefer command line parameters) (#23139) · Issues · CMake / CMake · GitLab ).

I tested this on a MacM1 with multiple python versions installed and got following Output during configuration:

-- Found Python3: /Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 (found version "3.12.0") found components: Development.Module 
-- Found Python3: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 (found version "3.10.2") found components: Interpreter Development.Embed 
-- Found Python3: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 (found version "3.10.2") found components: Interpreter

Note that although the first line seems wrong, it still set the correct include path while building. (You can verify that by looking at the generated CMakeCache.txt)

Best,
Matthias

After instead writing

cmake
-DPYTHON_EXECUTABLE =/opt/homebrew/Cellar/python@3.10/3.10.9/bin
-DPYTHON_INCLUDE_DIR=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10
-DPYTHON_LIBRARY=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib
-DCMAKE_INSTALL_PREFIX=/Applications/Netgen.app
-DNGSolve_DIR=/Applications/Netgen.app/Contents/Resources/CMake
-DBUILD_NGSOLVE=OFF
…/src-xfem

I was able to configure the project with the following warnings:

Traceback (most recent call last):
File “”, line 1, in
File “/Users/sebastianmyrback/Documents/ngsxfem/src-xfem/python/ngs_check.py”, line 7, in check_if_ngsolve_newer_than
import ngsolve
ModuleNotFoundError: No module named ‘ngsolve’
– Found Netgen: /Applications/Netgen.app/Contents/Resources/CMake

and

WARNING: Target “ngsxfem_py” requests linking to directory “/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.10/lib”. Targets may link only to libraries. CMake is dropping the item.
– Generating done

Then, when I write “make” I get the following error, following by many other errors:

[100%] Linking CXX shared library ngsxfem_py.so
Undefined symbols for architecture arm64:
“_PyBaseObject_Type”, referenced from:
pybind11::detail::make_object_base_type(_typeobject*) in python_ngsxfem.cpp.o