TityBoi
TityBoi

Reputation: 585

Conda environment not showing up in VS Code

I installed miniconda on Windows 10 and created an environment (I followed this guide: https://www.notion.so/shashankkalanithi/Setting-Up-Conda-Environment-ba83f7f019ea44b9af37588eed419eb9). However when I open the VS Code I don't see that environment python interpeter on kernel list. There is only one interpreter on the list: ~\Miniconda3\python.exe

How can I fix this?

Upvotes: 39

Views: 104476

Answers (16)

Shchurov.nk
Shchurov.nk

Reputation: 1

I had the same issue.

Only setting up the Anaconda Python interpreter path in VS code didn't work.

Try reinstalling Python extention in VS code - as described in this microsoft vscode issue: https://github.com/microsoft/vscode-docs/issues/3839

For me it solved the problem.

Upvotes: 0

Nilupul Manodya
Nilupul Manodya

Reputation: 52

In my case, Python: Select Interpreter did not show until I installed the Python extension for Visual Studio Code. After installation, I was able to follow these instructions.

Upvotes: 1

edgarbc
edgarbc

Reputation: 406

You need to reload the environments if you created your environment after you launched VSCode. You can do this simply by restarting your vscode or as suggested, ctrl+shift+p on win or cmd+shit+p on mac.

Upvotes: 1

Zhiyin Pan
Zhiyin Pan

Reputation: 1

I encountered the same problem. although I have conda env created and activated, the python interpreter selector does not show the target env I want;

I removed all the unused envs, and the one I want shows up in the selection.

Hope this helps.

Upvotes: 0

Praveen
Praveen

Reputation: 198

I added anaconda scripts(C:\Users\yesyou\Anaconda3\Scripts) to the user environment variable PATH and did conda init cmd.exe on my default command prompt. Once I was able to activate conda environment on my default shell of vscode (command prompt in my case), Select interpereter drop-down menu started showing python interpreters inside conda environments.

Upvotes: 0

Sehar Fatima
Sehar Fatima

Reputation: 1

I have an environment with python installed but it still don't show up often in my VS Code. The only solution that has worked for me every time is restarting VSC and everything works fine.

Upvotes: -1

Mark Chen
Mark Chen

Reputation: 61

You may check and set up the Conda path. It seems VS code has some problem to find the envs installed. You can go to Setting and search "Conda". Find "Python: Conda Path", and add the path of executable conda. Good luck!

Upvotes: 6

ZenithX
ZenithX

Reputation: 1

The reason why vscode doesn't show the environment is that it doesn't have a python interpreter in it because of inheriting or something.

The solution is also simple. Just manually install python in that environment.

conda install python

Upvotes: -5

igorkf
igorkf

Reputation: 3565

I finally resolved the problem.
This thread says that you need to create the conda environment passing the python argument:

conda create -n your_env_name python=3.7

Doing this the environment appears in the Select interpreter to start Jupyter server options.

Upvotes: 1

derivmug
derivmug

Reputation: 223

I wanted to use the new environment as a Jupyter kernel and had to install the jupyter package for it to show up in the kernel selection of VSCode. You can install it by running conda install jupyter.

Upvotes: 7

EngAAA
EngAAA

Reputation: 1

I had the same problem. After I opened Anaconda Prompt as Administrator and created the environment, I saw it in VS code

Open “Anaconda Prompt” from the Windows start button as “Administrator.”

Upvotes: 0

Rheatey Bash
Rheatey Bash

Reputation: 847

Firstly you need to create an environment with python in it otherwise it won't recognize it. Create an environment like this first

conda create --name tf26 python==3.10

Use your preferred name and python version here thereafter restart VS Code. You will definitely see your env.

Note: You can delete any unused env if want like this

conda env remove --name <env_name>

Upvotes: 3

Igor Micev
Igor Micev

Reputation: 1652

In your project .vscode/settings.json file, just replace the old python.pythonPath setting with the new one (or add if non-existing) python.defaultInterpreterPath and it will work. The value for the setting is the path to the venv you're using in your project.

Afterward, Ctrl+Shift+P via Python: Select Interpreter will allow you to choose a different interpreter.

Upvotes: 0

Hao-Chieh Kuo
Hao-Chieh Kuo

Reputation: 347

You can try to follow methods from vscode - Create a conda environment

Additional notes: ...To ensure the environment is set up well from a shell perspective, one option is to use an Anaconda prompt with the activated environment to launch VS Code using the code . command. At that point you just need to select the interpreter using the Command Palette or by clicking on the status bar.

Upvotes: 14

Steven-MSFT
Steven-MSFT

Reputation: 8411

The extension automatically looks for interpreters in the following locations:

Conda environments that contain a Python interpreter. VS Code does not show conda environments that don't contain an interpreter.

After you create a conda environment, you need to activate it and install some packages in order to get the python interpreter. And remember to reload the VSCode. If it still does not exist, you can try to choose Enter interpreter path, to point the path manually.

Upvotes: 0

se7en
se7en

Reputation: 870

in vscode press ctrl+shift+p and type python:Select Interpreter you should see all the environment there. If it does not appear create a .py file and try again. also you can press the reload icon on the search bar where you typed python:select interpreter.

Upvotes: 33

Related Questions