vscode1.96 调试python3.10.14提示ModuleNotFoundError: No module named '_ctypes'

环境:ubuntu24.04 + vscode1.96.2 + ms-python.debugpy 2024.14.0
python3.10.14 编译的 python3.10 -m venv 创建的虚拟环境在 /opt/目录 ,在 pycharm 下调试一切正常。在 vscode 老是提示 ```javascript
ModuleNotFoundError: No module named ‘_ctypes’。


```bash
sudo apt-get install build-essential libffi-dev   # 这个是有安装的
Traceback (most recent call last):
  File "/usr/local/python3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/python3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/.vscode/extensions/ms-python.debugpy-2024.14.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/__main__.py", line 91, in <module>
    main()
  File "/home/ubuntu/.vscode/extensions/ms-python.debugpy-2024.14.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/__main__.py", line 18, in main
    from debugpy.launcher import debuggee
  File "/home/ubuntu/.vscode/extensions/ms-python.debugpy-2024.14.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/launcher/debuggee.py", line 6, in <module>
    import ctypes
  File "/usr/local/python3.10/lib/python3.10/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
最佳答案

研究好久,经历几天,只要重新编译,命令完全一样,就可以了,只要几分钟,浪费怎么多时间,这个世界真奇怪,希望对别人有用,不要浪费生命

./configure --prefix=/usr/local/python3.10 --enable-optimizations

sudo make -j $(nproc) && sudo make altinstall
1个月前 评论
讨论数量: 1

研究好久,经历几天,只要重新编译,命令完全一样,就可以了,只要几分钟,浪费怎么多时间,这个世界真奇怪,希望对别人有用,不要浪费生命

./configure --prefix=/usr/local/python3.10 --enable-optimizations

sudo make -j $(nproc) && sudo make altinstall
1个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!