skip to Main Content

I’m working with Visual Code and Python 3 and am getting a

ModuleNotFoundError: No module named ‘_ctypes’ error.

error on my laptop. ( A similar setup works on my desktop )

It turns out that VS code is pointing to a python version installed by chocolatey.

I was able to fix it by changing to a different local python installation Following this
Module not found error in VS code despite the fact that I installed it

but the next time I restarted VS Code the problem returned.
Can I either make VS Code keep using the new installation, or otherwise fix the chocolatey installation?

( the problem with chocolatey python may be related to this question, but I’m not sure how to fix it in chocolatey )
Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing

I would love some help with either one of these directions.

2

Answers


  1. Try to swap interpreter by clicking on the bottom right corner as in the stamp below and select the desired python version.

    python_interpreter

    If nothing besides the chocolatey one appears, try to manually locate the one you want to use like clicking on the plus icon and navigating to the python folder.

    click_here_if_no_version_is_found

    Login or Signup to reply.
  2. Choose the correct interpreter for your python extension (Ctrl+Shift+P –> Python:Select Interpreter).

    Execute scripts using the official extension Python.

    enter image description here

    You can add the following configuration to settings.json to specify the default interpreter, and then select it in the Select Interpreter panel

        "python.defaultInterpreterPath": "E:\workspace\py12\.venv\Scripts\python.exe",
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search