'How to install ctypes module for python 3.7 to be used with VSCode debugger
I have multiple python interperters in my computer 3.7 and 3.8. When I debug using with python 3.8 I do not face any issues using VSCode. My VScode python debugger fails when trying to debug with python 3.7. How do I install ctypes for python 3.7?
File "/home/kumar/.vscode/extensions/ms-python.python-2021.5.842923320/pythonFiles/lib/python/debugpy/launcher/../../debugpy/launcher/debuggee.py", line 8, in <module>
import ctypes
File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Solution 1:[1]
Try pip uninstall ctypes, and then uninstall and reinstall ur python 3.7 and then try again pip install ctypes and then import ctypes in python interpreter.
Solution 2:[2]
Have you checked which pip you are using? Make sure you have taken the right pip to install the package in the right place.
You can take pip --version command to check which pip you are using.
Solution 3:[3]
ctypes is a built in library (I think from python2.5) This means you dont need to install it, it is coming built in when you install python.
As far as using the correct version, see the pyenv module - it will make sure you are running the correct python version, and IMO makes life much easier
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Parvanshu Sharma |
| Solution 2 | Steven-MSFT |
| Solution 3 | Gai Ashkenazy |
