简体   繁体   English

ModuleNotFoundError:没有名为“_ctypes”的模块 Mac M1

[英]ModuleNotFoundError: No module named '_ctypes' Mac M1

While installing some libraries you may find the issue ModuleNotFoundError: No module named '_ctypes'在安装一些库时,您可能会发现问题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 ).尝试使用 pyenv 安装 python 3.7.13pyenv install 3.7.13 ,如果不起作用,请尝试 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 . pyenv 版本 2.2.3解决了 M1 mac 上 3.6.15/3.7.12 的编译问题,特别是针对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. _ctypes错误的根本原因似乎是在编译期间找不到 libffi,因此在 Python 安装期间(默默地)跳过。

There is a comprehensive overview for installing different versions using pyenv at this page , some specific versions require homebrew patches. 在此页面上有使用 pyenv 安装不同版本的全面概述,某些特定版本需要自制补丁。 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.但是,我会先尝试在不安装补丁的情况下安装它们,因为 pyenv 团队已经修复了自那篇文章撰写以来的各种编译问题。

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.使用补丁安装的一般语法是: pyenv install --patch XXX <<(curl -sSL link_to_patch)其中XXX是您要安装的版本。

Another solution is to use an x86 version of homebrew .另一种解决方案是使用 x86 版本的 homebrew

Officially, Python 3.7 and lower are not supported on Apple Silicon . Apple Silicon 正式不支持 Python 3.7 及更低版本

Updating to Python 3.7.13 (or higher versions) should solve the problem.更新到 Python 3.7.13(或更高版本)应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mac M1 Spyder:ModuleNotFoundError:没有名为“lxml”的模块 - Mac M1 Spyder : ModuleNotFoundError: No module named 'lxml' Mac M1“没有名为‘pymunkoptions’的模块” - Mac M1 "No module named 'pymunkoptions' " 没有名为 [mtcnn] 的模块 - m1 Mac - python - No module named [mtcnn] - m1 Mac - python ModuleNotFoundError:M1 Macbook pro 中没有名为“mysql”的模块 - ModuleNotFoundError: No module named 'mysql' in M1 Macbook pro linux ModuleNotFoundError:没有名为&#39;_ctypes的模块 - linux ModuleNotFoundError: No module named '_ctypes pyenv 失败:ModuleNotFoundError: No module named &#39;_ctypes&#39; 错误 - pyenv fails with : ModuleNotFoundError: No module named '_ctypes' error ModuleNotFoundError:安装库时没有名为“_ctypes”的模块 - ModuleNotFoundError: No module named '_ctypes' while installing libraries Pyinstaller 错误:ModuleNotFoundError:没有名为“ctypes”的模块 - Pyinstaller Error: ModuleNotFoundError: No module named 'ctypes' ModuleNotFoundError 在 Mac 上的终端中没有命名模块 - ModuleNotFoundError no module named in Terminal on Mac Python导入错误ModuleNotFoundError:停电后没有名为“ _ctypes”的模块 - Python import error ModuleNotFoundError: No module named '_ctypes', after power outage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM