pythonvisual-studio-code

VSCode "Python: Select interpreter" add a custom path


I'm trying to run a python executable that is a plugin to an application (Unreal Engine). When I do CTRL + ALT + P and do select python interpreter it only shows me the system installed python interpreter and the virtual envs. How can I add a searchpath?


Solution

  • You can add a python.defaultInterpreterPath setting in the settings.json file of your workspace.

    From Manually specify an interpreter:

    If VS Code doesn't automatically locate an interpreter you want to use, you can browse for the interpreter on your file system or provide the path to it manually.

    If you want to manually specify a default interpreter that will be used when you first open your workspace, you can create or modify an entry for the python.defaultInterpreterPath setting.

    For example, in your workspace's .vscode/settings.json:

    {
        "python.defaultInterpreterPath": "/path/to/your/custom/python"
    }
    

    Make sure to reload VS Code after setting the defaultInterpreterPath. If it works, every time you open the workspace, it will automatically use that Python interpreter.

    Note that:

    Changes to the python.defaultInterpreterPath setting are not picked up after an interpreter has already been selected for a workspace; any changes to the setting will be ignored once an initial interpreter is selected for the workspace.