ModuleNotFoundError: No module named '_ctypes' error on macOS Big Sur even after installing libffi

1.9k Views Asked by At

I have been trying to install flask via pip3 on my Mac, but I keep running into this error. I tried installing libffi through brew, and reinstalling python but still does not work.

ERROR: Command errored out with exit status 1:
     command: /Users/prachimodi/Desktop/api/.venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zs/w0tb5f4d6dd_c098p_y7f5_r0000gn/T/pip-install-j9j3d44b/MarkupSafe/setup.py'"'"'; __file__='"'"'/private/var/folders/zs/w0tb5f4d6dd_c098p_y7f5_r0000gn/T/pip-install-j9j3d44b/MarkupSafe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/zs/w0tb5f4d6dd_c098p_y7f5_r0000gn/T/pip-pip-egg-info-fb3uduhe
         cwd: /private/var/folders/zs/w0tb5f4d6dd_c098p_y7f5_r0000gn/T/pip-install-j9j3d44b/MarkupSafe/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/prachimodi/Desktop/api/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 19, in <module>
        from setuptools.dist import Distribution
      File "/Users/prachimodi/Desktop/api/.venv/lib/python3.7/site-packages/setuptools/dist.py", line 34, in <module>
        from setuptools import windows_support
      File "/Users/prachimodi/Desktop/api/.venv/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
        import ctypes
      File "/Users/prachimodi/.pyenv/versions/3.7.9/lib/python3.7/ctypes/__init__.py", line 7, in <module>
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
0

There are 0 best solutions below