Question: I am trying to install greenlet in a virtualenv on my mac. pip install greenlet  This renders the following output: Collecting greenlet Using cached greenlet-2.0.1.tar.gz (163 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: greenlet Building wheel for greenlet (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [98 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-39 creating build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet creating build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform creating build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_version.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_weakref.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_gc.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/leakcheck.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_generator.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_greenlet_trash.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_throw.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_tracing.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_cpp.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_contextvars.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_greenlet.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_extension_interface.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_generator_nested.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_stack_saved.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_leaks.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests running egg_info writing src/greenlet.egg-info/PKG-INFO writing dependency_links to src/greenlet.egg-info/dependency_links.txt writing requirements to src/greenlet.egg-info/requires.txt writing top-level names to src/greenlet.egg-info/top_level.txt reading manifest file 'src/greenlet.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files found matching 'benchmarks/*.json' no previously-included directories found matching 'docs/_build' warning: no files found matching '*.py' under directory 'appveyor' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyd' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution warning: no previously-included files matching '.coverage' found anywhere in distribution adding license file 'LICENSE' adding license file 'LICENSE.PSF' adding license file 'AUTHORS' writing manifest file 'src/greenlet.egg-info/SOURCES.txt' copying src/greenlet/greenlet.cpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_allocator.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_compiler_compat.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_cpython_compat.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_exceptions.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_greenlet.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_internal.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_refs.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_slp_switch.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_thread_state.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_thread_state_dict_cleanup.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_thread_support.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/slp_platformselect.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/platform/setup_switch_x64_masm.cmd -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_aarch64_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_alpha_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_amd64_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm32_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm32_ios.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm64_masm.asm -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm64_masm.obj -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm64_msvc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_csky_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_m68k_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_mips_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc64_aix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc64_linux.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_aix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_linux.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_macosx.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_riscv_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_s390_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_sparc_sun_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x32_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x64_masm.asm -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x64_masm.obj -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x64_msvc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x86_msvc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x86_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/tests/_test_extension.c -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/_test_extension_cpp.cpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests running build_ext building 'greenlet._greenlet' extension creating build/temp.macosx-10.9-universal2-cpython-39 creating build/temp.macosx-10.9-universal2-cpython-39/src creating build/temp.macosx-10.9-universal2-cpython-39/src/greenlet clang -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 -I/Users/alexanderk/Library/CloudStorage/Dropbox/Mac/Documents/Development/Python-Dev/testCHat/env/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c src/greenlet/greenlet.cpp -o build/temp.macosx-10.9-universal2-cpython-39/src/greenlet/greenlet.o --std=gnu++11 src/greenlet/greenlet.cpp:16:10: fatal error: 'Python.h' file not found #include <Python.h> ^~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for greenlet Running setup.py clean for greenlet Failed to build greenlet Installing collected packages: greenlet Running setup.py install for greenlet ... error error: subprocess-exited-with-error × Running setup.py install for greenlet did not run successfully. │ exit code: 1 ╰─> [100 lines of output] running install /Users/alexanderk/Library/CloudStorage/Dropbox/Mac/Documents/Development/Python-Dev/testCHat/env/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-39 creating build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet creating build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform creating build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_version.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_weakref.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_gc.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/leakcheck.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_generator.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_greenlet_trash.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_throw.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_tracing.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_cpp.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_contextvars.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_greenlet.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_extension_interface.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_generator_nested.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_stack_saved.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/test_leaks.py -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests running egg_info writing src/greenlet.egg-info/PKG-INFO writing dependency_links to src/greenlet.egg-info/dependency_links.txt writing requirements to src/greenlet.egg-info/requires.txt writing top-level names to src/greenlet.egg-info/top_level.txt reading manifest file 'src/greenlet.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files found matching 'benchmarks/*.json' no previously-included directories found matching 'docs/_build' warning: no files found matching '*.py' under directory 'appveyor' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyd' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution warning: no previously-included files matching '.coverage' found anywhere in distribution adding license file 'LICENSE' adding license file 'LICENSE.PSF' adding license file 'AUTHORS' writing manifest file 'src/greenlet.egg-info/SOURCES.txt' copying src/greenlet/greenlet.cpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_allocator.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_compiler_compat.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_cpython_compat.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_exceptions.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_greenlet.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_internal.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_refs.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_slp_switch.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_thread_state.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_thread_state_dict_cleanup.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/greenlet_thread_support.hpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/slp_platformselect.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet copying src/greenlet/platform/setup_switch_x64_masm.cmd -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_aarch64_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_alpha_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_amd64_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm32_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm32_ios.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm64_masm.asm -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm64_masm.obj -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_arm64_msvc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_csky_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_m68k_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_mips_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc64_aix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc64_linux.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_aix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_linux.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_macosx.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_ppc_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_riscv_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_s390_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_sparc_sun_gcc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x32_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x64_masm.asm -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x64_masm.obj -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x64_msvc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x86_msvc.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/platform/switch_x86_unix.h -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/platform copying src/greenlet/tests/_test_extension.c -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests copying src/greenlet/tests/_test_extension_cpp.cpp -> build/lib.macosx-10.9-universal2-cpython-39/greenlet/tests running build_ext building 'greenlet._greenlet' extension creating build/temp.macosx-10.9-universal2-cpython-39 creating build/temp.macosx-10.9-universal2-cpython-39/src creating build/temp.macosx-10.9-universal2-cpython-39/src/greenlet clang -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 -I/Users/alexanderk/Library/CloudStorage/Dropbox/Mac/Documents/Development/Python-Dev/testCHat/env/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c src/greenlet/greenlet.cpp -o build/temp.macosx-10.9-universal2-cpython-39/src/greenlet/greenlet.o --std=gnu++11 src/greenlet/greenlet.cpp:16:10: fatal error: 'Python.h' file not found #include <Python.h> ^~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> greenlet note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.  I have read a multitude of similar problems and solutionsbut none of them seem to work. My setuptools are up to date. My wheel is up to date. My python version is 3.9.6 My mac is up to date. I have XCode commandline tools installed. Please help me adress this error so I can install greenlet and other python packages (some packages install fine, others give the same error)

Answer: Solution: Turns out my whole pip/python-versions etc. mess was causing the issue. I followed this wonderfully written article and everything is working now: https://gist.github.com/MuhsinFatih/ee0154199803babb449b5bb98d3475f7