virtual environment python not found / can’t be selected on vs code

quick note to self:

for my environment I usually set it up in a random folder (most people seem to set it up in ~/.env) and vscode has difficulty finding it

(in which case it keeps saying “Running cell with Python xxxx 64-bit requires ipykernel package” since I only install my packages in my virtualenv)

Here is how I solved it:

Put in the User settings (in this case I’m working remotely (via remote ssh extension) but applies locally too)

And then put a defaultInterpreterPath into the settings

    // "python.pythonPath": "~/v3/bin/python",
    "python.terminal.activateEnvironment": true,
    "python.defaultInterpreterPath": "~/v3/bin/python",

And then it shows up when I change the kernel (see third option):


May require a .vscode folder (with empty settings.json) in the parent repository?