Joris
Joris

Reputation: 77

Python path in VSCode

I have an Anaconda distribution installed on Mac OSX (10.14.2). With it, I installed VSCode which I'm to write python scripts. Recently, I've updated some environments in Anaconda and something happened with the configuration of the python path VSCode uses for its integrated terminal: when I run my code, an ImportError comes up for the joblib package that I now have installed in my conda environment (also happens for other packages), which doesn't happen when I run the same code in a regular terminal.

Using conda list in the integrated terminal gives me the correct list of packages for the environment I'm using, and conda env list indicates that indeed this specific environment should be active. However, I can see that that something is off, because in my normal terminal I get:

$ which python
python is /Users/Joris/anaconda3/envs/astro3/bin/python
python is /usr/bin/python

While in the VSCode terminal:

$ which python
python is /usr/bin/python
python is /Users/Joris/anaconda3/envs/astro3/bin/python

I've tried changing some of the VSCode settings, like manually pointing python.pythonPath and python.venvPath to my anaconda environment folders. (The setting python.terminal.activateEnvironment is set to true.) Also, reinstalling VSCode through the Anaconda distribution does not seem to help. So unfortunately, I can't seem to get VSCode to run python with my Anaconda environment which contains the packages I need.

Upvotes: 3

Views: 4804

Answers (1)

Alex Hou
Alex Hou

Reputation: 133

  1. Press (macOS): ++P, (Linux/Windows: Ctrl+Shift+P) in VS Code.
  2. Type: python select interpreter
  3. Select /Users/Joris/anaconda3/envs/astro3/bin/python
  4. Test if your lib is usable.

Upvotes: 2

Related Questions