简体   繁体   中英

adding multiple virtualenv to python interpreter using visual studio code

I searched literally everywhere and I can't figure out how to add multiple python interpreters with visual studio code. By the way, I'm quite new to visual studio code.

I'm wondering if there something I need to do in the user settings to add multiple python.PythonPath directories. At the moment I only have 2 interpreter my venv and the default python interpreter

    "python.pythonPath": 
 "C:\\Users\\<name>\\Projects\\Test\\Venv\\Scripts\\python.exe",

The setting "python.pythonPath": would normally apply to your workspace settings. So, if you have multiple projects, vscode will the interpreter for each project automatically.

To switch once your project is open, open the command palette ( shift + cmd + P or F1 ) and type '>Python: Select Interpreter' to choose between the interpreters available to your project.

If you store your virtual enviornments in a non-defeault location, you can use the settings python.venvFolders and python.venvPath in to tell vscode where to find them.

If that is not enough, you could create a tasks.json to specify command including the exact paths, ie:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run mock",
            "type": "shell",
            "command": "pipenv run ./run.py --mock",
            "problemMatcher": [
                "$eslint-compact"
                ]
         },
    ],
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM