user10104344
user10104344

Reputation:

Anaconda Environment on VS Code

In general I am new to python so keep it easy. I have started my coding in Spyder since it was easy to install libraries with Anaconda.

Now we want to switch to VS Code for version control. I have switched interpreter and python path to Anaconda folder, but if I open python files I have created in Spyder I can't use in VS code, issue always is with importing libraries.

Screenshot

Upvotes: 0

Views: 2194

Answers (1)

Peter
Peter

Reputation: 12295

The first rule with Anaconda is to not manually mess around with the paths. Anaconda has a different philosophy: Before you can use Python, you need to activate a conda environment.

c:\> conda activate
(Anaconda3) c:\> python
>>>

VSCode detects conda environments and you just have to select one for your project (Python: Select interpreter). Now open a new terminal and watch VSCode activating the environment for you (like shown above).

However, when you start your script for the first time, VSCode sometimes invokes the interpreter even before the conda activation has finialized. Then simply restart your script.

Upvotes: 1

Related Questions