While installing some libraries you may find the issue ModuleNotFoundError: No module named '_ctypes'
确保您正在运行 python 3.8.10 +
Short version:
Try installing python 3.7.13 with pyenv : pyenv install 3.7.13
, and if that does not work, try python 3.7.12 ( pyenv install 3.7.12
).
The pyenv release 2.2.3 addresses the compilation problems for 3.6.15/3.7.12 on M1 macs, specifically for ctypes .
Long version:
The underlying cause for the _ctypes
error seems to be that libffi cannot be found during the compilation, and is therefore (silently) skipped during the Python installation.
There is a comprehensive overview for installing different versions using pyenv at this page , some specific versions require homebrew patches. Here is an overview of those patches . However, I would try installing them without the patches first, as the pyenv team has fixed various compilation problems since that post was written.
The general syntax for installing with a patch is: pyenv install --patch XXX <<(curl -sSL link_to_patch)
where XXX
is the version you want to install.
Another solution is to use an x86 version of homebrew .
Officially, Python 3.7 and lower are not supported on Apple Silicon .
Updating to Python 3.7.13 (or higher versions) should solve the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.