没有名为“_ctypes”的模块

问题描述 投票:0回答:1

我在 Ubuntu v22.04 中使用 VSCode。当我运行 Python v3.11.3 调试时,我收到一条错误消息:

(.venv) ➜ ProjectEuler git:(master) ✗ /usr/bin/env /home/samu/PythonProjects/Persoal/ProjectEuler/.venv/bin/python /home/samu/.vscode/extensions/ms-python。 python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 58743 -- /home/samu/PythonProjects/Persoal/ProjectEuler/Exercise_3.py 回溯(最近一次调用最后一次): 文件“”,第 198 行,位于 _run_module_as_main 中 文件“”,第 88 行,在 _run_code 中 文件“/home/samu/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/main.py”,行91、在 主要的() 文件“/home/samu/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/main.py”,行18、主要 从 debugpy.launcher 导入调试对象 文件“/home/samu/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/ launcher/debuggee.py”,第 6 行,在 导入ctypes 文件“/usr/local/lib/python3.11/ctypes/init.py”,第 8 行,位于 from _ctypes import 联合、结构、数组 ModuleNotFoundError:没有名为“_ctypes”的模块

我在 stackoverflow 和其他论坛中寻找一些帮助,我发现了一些可能的解决方案,例如这个 可能的解决方案 1 但它对我不起作用。

我也发现很多人都无法解决这个问题,有什么建议吗?非常感谢。

python ctypes visual-studio-debugging
1个回答
0
投票

由于您的操作系统是 Ubuntu,请尝试安装 'libffi-dev' 软件包:

sudo apt-get install libffi-dev

从官方文档你可以知道:

libffi

谁使用它?

CPython - Python 的默认、最广泛使用的实现 编程语言使用标准 ctypes 库中的 libffi。

此包是

_ctypes
模块的依赖项。
libffi-dev
包提供了 Python 用于调用 C 函数和操作 C 数据类型的外部函数接口库。

© www.soinside.com 2019 - 2024. All rights reserved.