Does the Python virtual environment not support C ++ extensions

I write a cpp extension demo like Custom C++ and CUDA Extensions, but much simpler.

In a physical python environment, it work well, but when I switched to a python virtual environment (python -m venv venv), it raise error. setuptools and Just in Time (JIT) are both. The former will report an error during installation, while the latter will report an error during runtime.

ImportError: No module named 'test_cpp'

I setting verbose=True in JIT mode. I see the directory where the cpp extension was exists, but there is no .o file in the directory.

I don’t know why. Is it that the Python virtual environment does not support cpp extensions? or do I need some extra settings?

I don’t believe the virtual environment is itself causing the issue, but I guess packages are not installed correctly.
Could you post a minimal code snippet reproducing the issue raised only in a virtual env?

Thanks for your answer. I have located the problem, mainly because some environment variables are not set correctly, and I made the wrong modification on cpp_extension.py according to a blog on the Internet.