Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I activate my conda environment for VS Code python debugger and testing?

When I try to run the debugger:

C:\Users\Philip\OneDrive\Betting\Capra\Tennis\polgara> cmd /C "C:/Users/Philip/miniconda3/envs/capra/python.exe c:\Users\Philip\.vscode\extensions\ms-python.python-2020.8.101144\pythonFiles\lib\python\debugpy\launcher 53607 -- c:\Users\Philip\OneDrive\Betting\Capra\Tennis\polgara\updater.py "
C:\Users\Philip\miniconda3\envs\capra\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init

I've worked out that if I install numpy into my base environment then I can get around the error. The question is how to activate the capra environment for the debugger?

I've tried following the guidance from VS Code:

1. pythonPath property of the selected debug configuration in launch.json

My launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "pythonPath": "C:/Users/Philip/miniconda3/envs/capra/python.exe"
        }
    ]
}

Next:

2. python.pythonPath setting in the workspace settings.json

I restart VS Code and get:

We removed the "python.pythonPath" setting from your settings.json file as the setting is no longer used by the Python extension. You can get the path of your selected interpreter in the Python output channel. [Learn more](https://aka.ms/AA7jfor).

Lastly:

3. python.pythonPath setting in the user settings.json

My user settings file:

{
    "terminal.integrated.shell.windows": "C:/WINDOWS/System32/cmd.exe",
    "kite.showWelcomeNotificationOnStartup": false,
    "python.venvPath": "C:/Users/Philip/miniconda3/envs/capra",
    "python.pythonPath": "C:/Users/Philip/miniconda3/envs/capra/python.exe",
    "terminal.integrated.automationShell.windows": "C:/WINDOWS/System32/cmd.exe",
    "python.autoComplete.extraPaths": [
    
    ]
}

Still get the same numpy error.

Worth mentioning that I get exactly the same error when I look at the Python Test Log output after trying to discover tests.

like image 935
Jossy Avatar asked Aug 03 '26 14:08

Jossy


1 Answers

You click on the Python 3.6 ..... bottom right side as shown in the picture below Click on red square part Python 3.6. ....

Then you just have to select the environments you have already created as shown in the picture below Select the environment in red circle

Then you run the code and code will run in the selected environment.

like image 148
Imran Avatar answered Aug 05 '26 08:08

Imran