9

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

Wenhao Xu
  • 91
  • 1
  • 1
  • 4

3 Answers3

9

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.

JialeDu
  • 6,021
  • 2
  • 5
  • 24
3

4 days ago, 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 !

greg245
  • 644
  • 1
  • 3
  • 5
  • That works only if you don't use anaconda such as conda create -n my_conda_env_with_py311 python=3.11 anaconda – gench Jun 04 '23 at 10:18
  • @gench, I am not sure to understand your comment, could you elaborate ? – greg245 Jun 05 '23 at 07:54
  • This doesnt work: "conda create -n my_conda_env_with_py311 python=3.11 anaconda" – gench Jun 11 '23 at 12:30
  • @gench Oh okay. Well I do not include anaconda in the command usually, so I do not really know how to fix your issue sorry about that – greg245 Jun 12 '23 at 13:22
1

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

Tzane
  • 2,752
  • 1
  • 10
  • 21
  • Why are you using a `--prefix` and a hidden folder at that? That's just unnecessary confusion for users. – merv Dec 30 '22 at 17:27
  • @merv I understood from OPs first screenshot he wants to create the conda environment in the workspace directory in that folder. Naming the folder differently or using `--name` instead works just as well if that's more to your liking. – Tzane Dec 31 '22 at 20:04