Configuring PyCharm for FEniCSx installed on macOS (via conda)

Dear all,
I’m a new user of FEniCSx and learning it for my research. I have a question regarding the configuration of PyCharm for using FEniCSx installed on macOS via conda.

Installation and system details
System details:
MBP (Apple M2 chip) with Sonoma 14.3
Installation details:
I installed FEniCSx using conda as recommended on the GitHub README

Problem Description
To check my installation, I ran the code from PyCharm IDE. However, I get the following error:

cffi.VerificationError: CompileError: command ‘/Users/kau/opt/miniconda3/envs/fenics/bin/clang’ failed with exit code 1

This is caused when creating function space V on the mesh: V = fem. function space(msh, ("Lagrange", 1)) because of the following message

In file included from Libffcx_elements_6d5ea566818a6d6eef9b766d19b87bfe92
54cbdd.c: 57:
/Users/kau/opt/miniconda3/envs/fenics/ include/python3.12/Python.h:23:12: fatal error: ’ stdlib.h’ file not found
# include <stdlib.h>

Workaround solution
I found that when I run the Python script directly via the terminal, it executes perfectly as intended. After the execution via the terminal, if I run the same script via PyCharm, it works as well.
However, if I change my mesh and function space, then the code again throws the same error (when I run it directly via PyCharm), and I need to run it via the terminal to be able to run it via PyCharm.

Is there a way with which I can run the code in the first go via PyCharm? Any plugins, changes in environment variables or packages?

Thank you for any help that you can provide.

Did you find a reliable solution? I am having the same issue with a Jupyter notebook running in VSCode on MacOS Sonoma.

No, unfortunately not. I still use the workaround solution. :frowning_face: