0

I have:

  • two conda environments, myenv1 and myenv2;
  • two folders containing .py files: folder1 and folder2.

Let's say I've been working on folder1 in VS Code using myenv1, and then I do the following:

  • I close folder1 (using File -> Close Folder)
  • I open folder2 (using File -> Open Folder...).
  • I switch to env2 using the Python: Select Interpreter command.

What happens?

  • The blue information bar at the bottom of the VS Code window says "Python 3.8.2 64-bit ('env2': conda)" -- this suggests to me I'm now working in env2.
  • But I don't think the VS Code has correctly switched to env2. Why? Because if I attempt to import a package that exists in env2 but not env1 I get an error. If I import a package that exists in env1 but not env2 the import is successful.

But if I close VS Code and open it again (without doing anything else), the switch to env2 has been successful (by performing the same import test).

Is this a known bug, or am I doing something wrong? I've tried to find the issue on github without success.

Many thanks for your help.

Frank.

PS: I guess I could manually set sys.executable but I'd like to use the VS Code functionality if possible.

Frank
  • 223
  • 3
  • 11
  • What is the exact error you are getting when trying to import? Is this in the editor or is it when you execute code? And due to how conda wants to own the environment it's easiest to launch VS Code from the activated environment you want to work with. – Brett Cannon May 12 '20 at 23:23
  • @BrettCannon It's a `ModuleNotFoundError`. I will try figure out how to launch VS Code as you suggest and see if this helps. – Frank May 26 '20 at 08:41

0 Answers0