Conda and Visual Studio Code debugging

前端 未结 3 417
余生分开走
余生分开走 2020-12-09 11:14

The goal is to be able to use my environment setup from Conda/Anaconda within the visual studio code debugger. The default pythonpath configuration does not produce this eff

相关标签:
3条回答
  • 2020-12-09 11:39

    When starting Visual Studio Code from an activated Conda environment, I was able to use the environment variable to specify the path (MacOS):

    {
        "python.pythonPath": "~/anaconda/envs/${env.CONDA_DEFAULT_ENV}/bin/python"
    }
    

    Go to Workplace Settings by pressing Cmd , or navigating from the top menu, then add this to settings.json

    0 讨论(0)
  • 2020-12-09 11:46

    I found a better solution, based on the previous ones:

    Go to Workplace Settings. Override the parameter python.venvPath with the Path to folder with a list of Virtual Environments. For the case of anaconda:

    This setting enables VS Code to recognize the available conda environments. Thus, we can click on the current python interpreter and switch to others:

    0 讨论(0)
  • 2020-12-09 12:02

    On MacOS, follow these steps:

    1. Install Python for VSCode (the most popular python extension)

    2. Go to Workplace Settings by pressing Cmd , or navigating from the top menu.

    1. Add the path of your specific conda environment, like seen above, to your settings.json file. You can find the paths of your conda environments by typing conda env list in terminal.

    2. Save and restart VS Code

    Now the debugger will automatically use that environment! As far as I know, you must do this individually for each project.

    For other ways of configuring your python path, here is a useful post by the extension author: https://github.com/DonJayamanne/pythonVSCode/wiki/Python-Path-and-Version

    0 讨论(0)
提交回复
热议问题