Question: I am trying to install gevent 21.12.0 on Mac OS Monterey (version 12.6) with python 3.9.6 and pip 21.3.1. But it is failing with the below error. Any suggestion? (venv) debrajmanna@debrajmanna-DX6QR261G3 qa % pip install gevent Collecting gevent Using cached gevent-21.12.0.tar.gz (6.2 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting greenlet<2.0,>=1.1.0 Using cached greenlet-1.1.3-cp39-cp39-macosx_10_9_universal2.whl Collecting zope.event Using cached zope.event-4.5.0-py2.py3-none-any.whl (6.8 kB) Collecting zope.interface Using cached zope.interface-5.4.0-cp39-cp39-macosx_10_9_universal2.whl Requirement already satisfied: setuptools in /Users/debrajmanna/code/python/github/spotnana/venv/lib/python3.9/site-packages (from gevent) (60.2.0) Building wheels for collected packages: gevent Building wheel for gevent (pyproject.toml) ... error ERROR: Command errored out with exit status 1: command: /Users/debrajmanna/code/python/github/spotnana/venv/bin/python /Users/debrajmanna/code/python/github/spotnana/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/tmpi2i_lqc2 cwd: /private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370 Complete output (46 lines): running bdist_wheel running build running build_py running build_ext generating cffi module 'build/temp.macosx-10.9-universal2-cpython-39/gevent.libuv._corecffi.c' Running '(cd "/private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370/deps/libev" && sh ./configure -C > configure-output.txt )' in /private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370 generating cffi module 'build/temp.macosx-10.9-universal2-cpython-39/gevent.libev._corecffi.c' Not configuring libev, 'config.h' already exists Not configuring libev, 'config.h' already exists building 'gevent.libev.corecext' extension Embedding c-ares <cffi.setuptools_ext._add_c_module.<locals>.build_ext_make_mod object at 0x104f40bb0> <_setuputils.Extension('gevent.resolver.cares') at 0x1048f4640> Inserted build/temp.macosx-10.9-universal2-cpython-39/c-ares/include in include dirs ['build/temp.macosx-10.9-universal2-cpython-39/c-ares/include', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9', '/private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370/deps', '/private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370/deps/c-ares/include', '/private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370/deps/c-ares/src/lib', 'src/gevent', 'src/gevent/libev', 'src/gevent/resolver', '.'] Running '(cd "/private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370/deps/c-ares" && if [ -r include/ares_build.h ]; then cp include/ares_build.h include/ares_build.h.orig; fi && sh ./configure --disable-dependency-tracking -C CFLAGS="-Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration" && cp src/lib/ares_config.h include/ares_build.h "$OLDPWD" && cat include/ares_build.h && if [ -r include/ares_build.h.orig ]; then mv include/ares_build.h.orig include/ares_build.h; fi) > configure-output.txt' in /private/var/folders/ls/b6mf3_jd17916k8bs8jwy2g80000gn/T/pip-install-qprhzmpd/gevent_54aaef476d2d411ba9ad080d0291a370/build/temp.macosx-10.9-universal2-cpython-39/c-ares/include configure: WARNING: Continuing even with errors mentioned immediately above this line. rm: conftest.dSYM: is a directory rm: conftest.dSYM: is a directory configure: WARNING: Continuing even with errors mentioned immediately above this line. building 'gevent.resolver.cares' extension building 'gevent._gevent_c_greenlet_primitives' extension building 'gevent._gevent_c_hub_primitives' extension building 'gevent._gevent_c_hub_local' extension building 'gevent._gevent_c_waiter' extension building 'gevent._gevent_cgreenlet' extension building 'gevent._gevent_c_tracer' extension building 'gevent._gevent_c_abstract_linkable' extension building 'gevent._gevent_c_semaphore' extension building 'gevent._gevent_clocal' extension building 'gevent._gevent_c_ident' extension building 'gevent._gevent_c_imap' extension building 'gevent._gevent_cevent' extension building 'gevent._gevent_cqueue' extension src/gevent/queue.c:7071:12: warning: unused function '__pyx_pw_6gevent_14_gevent_cqueue_5Queue_25__nonzero__' [-Wunused-function] static int __pyx_pw_6gevent_14_gevent_cqueue_5Queue_25__nonzero__(PyObject *__pyx_v_self) { ^ 1 warning generated. src/gevent/queue.c:7071:12: warning: unused function '__pyx_pw_6gevent_14_gevent_cqueue_5Queue_25__nonzero__' [-Wunused-function] static int __pyx_pw_6gevent_14_gevent_cqueue_5Queue_25__nonzero__(PyObject *__pyx_v_self) { ^ 1 warning generated. building 'gevent.libev._corecffi' extension building 'gevent.libuv._corecffi' extension build/temp.macosx-10.9-universal2-cpython-39/gevent.libuv._corecffi.c:50:14: fatal error: 'pyconfig.h' file not found # include <pyconfig.h> ^~~~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 ---------------------------------------- ERROR: Failed building wheel for gevent Failed to build gevent ERROR: Could not build wheels for gevent, which is required to install pyproject.toml-based projects 

Answer: Looked all over trying to figure out a solution to this problem until I finally stumbled on this post. I think the issue is specific to the virtual environment. I had the project open with it's own venv in PyCharm, and it seems that the python distribution headers were not findable. To reiterate the solution linked:  Find where the Python.h file is defined. I was able to find it using find /usr/local -name Python.h Copy the path to the directory Python.h is defined in Set the C_INCLUDE_PATH environment variable accordingly, for me: export C_INCLUDE_PATH="/usr/local/munki/Python.framework/Versions/3.9/include/python3.9"  After this, I was able to run pip3 install gevent with no issues.