Wenhao Xu
Wenhao Xu

Reputation: 191

How to pick python 3.11 as a conda environment in vs code

I am just start using vscode to write python code. And I am normally using conda as my package and environment tool.

I am trying to create a conda environment for python 3.11 in my project directory based on the instruction in the vscode official document https://code.visualstudio.com/docs/python/environments.

However, it only list python 3.7 - 3.10 as the python version I could choose.

I am wondering how could I pick python 3.11 in the conda environment?

I am using an Intel 2019 macbook pro. I already installed python3.11 through homebrew from command line. And I have also installed miniconda and created a python 3.11 environment through command line. However, when I tried to create .conda environment in vscode

Screenshot to create python environment

Screenshot to select python interpreter version for conda environment

It only show python 3.7 - 3.10

Upvotes: 19

Views: 68588

Answers (4)

Shital Shah
Shital Shah

Reputation: 68708

You will get this error with current llama.cpp version with Python 3.12. Fix is to create virtual environment with Python 3.11 and install llama.cpp there:

conda create -n gguf python=3.11 anaconda

Upvotes: 0

greg245
greg245

Reputation: 812

The 17th of April 2023, the support for python 3.11 was added to conda (see issue in the official repo)

You should now be able to download conda directly using:

conda create -n my_conda_env_with_py311 python=3.11

Vs code should soon (if not already) allow you to pick python 3.11 in their GUI for you conda env !

Upvotes: 9

Tzane
Tzane

Reputation: 3462

Python 3.11 is now available through the "standard" channels

conda create -p ./.venv python=3.11 

Old Answer

Right now, python 3.11 is still quite new so it's not yet available through the "standard" channels. You should still be able to install it with conda from the command line:

conda create -c conda-forge -p ./.venv python=3.11 

-c: Adds the "conda-forge" channel: https://anaconda.org/conda-forge/python

-p: Creates the virtial environment to the given path

Upvotes: 1

JialeDu
JialeDu

Reputation: 9727

This problem is related to conda, but it's not a vscode problem. You can create a conda environment with the following command,

conda create --name myenv -c conda-forge python=3.11

Then select the created conda interpreter in the Select Interpreter panel.

enter image description here

More information on conda commands.

Upvotes: 19

Related Questions