简体   繁体   中英

VSCode Mac shows incorrect interpreter even after activation of environment

Problem

I am new to VSCode so I was trying to use the existing conda environments as part of my project in VSCode. I was able to use Shift+Cmd+P to select the relevant interpreter

(in this case named mlops , as visible at the bottom right of the image below)

在此处输入图像描述

I was able to test that after selecting the interpreter, my code was actually using this, as displayed in the left side terminal window using the code below -

import sys
print("Interpreter:")
print(sys.executable)

Finally, I then went to another bash terminal (right side) and activated the conda environment. But, when I checked which python it still points to the wrong interpreter.


Attempts

I have gone through a large number of questions and solutions to solve this issue and most of them point to adding terminal.integrated.inheritEnv as False in the settings.json

But it doesn't seem to fix the issue.

My question is 2 fold:

  1. Why is this happening and is this only a mac/Linux issue?
  2. How do I fix this, in general, for my current and future projects?

This is a common problem. Switching between different environments will lead to confusion in the environment.

What we need to do is to deactivate all environments and then reactivating conda environment .

You can refer to this issue which is the same to your problem for more information.

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