Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activate conda environment stopped working in vscode

I have noticed that conda activate environment stopped working in vscode integrated terminal with no obvious reason (I certainly did not install any new extensions, nor updated conda or vscode in the last few days).

Expected behaviour

After running conda activate environment I want the environment to be activated and be capable of using the environment python interpreter. Essentially it should look like this:

(base) lpravda-ml:~ lpravda$ conda activate rdkit-env
(rdkit-env) lpravda-ml:~ lpravda$ which python
/Users/lpravda/anaconda3/envs/rdkit-env/bin/python

This is what I can achieve using non-vscode terminal and work with conda as usual.

Actual behaviour This happens when I type in the same set of commands in vscode integrated terminal:

(base) lpravda-ml:~ lpravda$ conda activate rdkit-env
(rdkit-env) lpravda-ml:~ lpravda$ which python
/usr/local/bin/python

The environment seems to be switched on, however python still points to the system install python 2.7 and I have no idea why.

It used to be working like for years and now it broke down.

Note: When I run debugger in vscode the correct conda environment is selected and executed.

My setup:

OS: Mac OS X: 10.14.3
vscode: 1.31.1
conda: 4.6.7

Update ongoing issue with the following update:

OS: Mac OS X: 10.14.3
vscode: 1.33.3
conda: 4.6.8

Any idea what could possibly broke down?

like image 416
lukas Avatar asked Feb 28 '19 09:02

lukas


People also ask

How do you activate conda environment in VS Code terminal?

Ctrl+Shift+P and search “Terminal”. In the Terminal window, you can see “conda activate <env>” command already executed, and the terminal is under your conda environment.

How do I open a conda environment in VS Code?

From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Create Environment command to search, and then select the command. The command presents a list of environment types: Venv or Conda.

How do you activate an already created conda environment?

To activate your Conda environment, type source activate <yourenvironmentname> . Note that conda activate will not work on Discovery with this version. To install a specific package, type conda install -n <yourenvironmentname> [package] . To deactivate the current, active Conda environment, type conda deactivate .


1 Answers

it is issue which you can read about it here, but I find this solution which solve the issue in this version. Also, as community said the problem with python interpreter and env gonna fix in next major update.

like image 102
Pooya Panahandeh Avatar answered Oct 15 '22 16:10

Pooya Panahandeh