-1

In VS Code (Windows), my python interpreter points to version 3.11. python -V in terminal gives me Python 3.11.0

I create a virtual environment with python3 -m venv virtual called virtual, and activate it with .\virtual\Scripts\activate. Now in my environment, checking python -V gives me Python 3.9.13 instead.

How do I get venv to create a Python 3.11 environment?

Desmond
  • 1,047
  • 7
  • 14
  • 1
    You are checking your "global" installation with `python -V`, but creating the virtual environment with `python3 -m ...`. Are `python` and `python3` the same thing? – chepner Oct 29 '22 at 15:56
  • How do I check? – Desmond Oct 29 '22 at 16:04
  • @chepner I deleted that virtual environment and created another with `python -m venv virtual` and its `python -V` is now 3.11! Thanks for pointing that out. On a related note, how do I get my `python3` to point to my latest python version? – Desmond Oct 29 '22 at 16:08

2 Answers2

1

You are creating virtual environment with python3 but checking version with just python. I want you to check if python and python3 are pointing same python executable file before creating virtual environment.

May be try creating virtual environment using just python, since its version is 3.11.0.

$ python -m venv virtual

Or you can create virtual environment with specifing the path of your python 3.11 executable file.

$ C:/path/to/your/python3-11-execuatable/python.exe -m venv virtual
Althaf
  • 72
  • 5
  • Yes it seems python3 and python are pointing to two different python executable files... how do I change the exec file that python3 points to? – Desmond Oct 29 '22 at 16:14
  • if just python is 3.11 then create venv using first command, and let me know if it works – Althaf Oct 29 '22 at 16:16
  • Yes using `python -m venv virtual` works. But a related qn - python3 is still not pointing to the latest python version. How do I fix that? – Desmond Oct 29 '22 at 16:18
  • i think for window's the standard executable is python.exe. may be the older version got python3.exe in the installed directory. python or python3 are just name of executable file. if you go to the installed directory and change the name of python.exe to something like viper.exe it still gonna work. But make sure the installed directory path is added in window's environment variable. – Althaf Oct 29 '22 at 16:28
0

In the view tab above click on Comand palette> python interpreter from there you can select python 3.11, otherwise you can add it by clicking on enter interpreter path and then select the path where python 3.11 is located at

Reactord
  • 96
  • 1
  • 11
  • As I mentioned in my question above, my interpreter is already pointing to 3.11 so this doesn't solve my question. – Desmond Oct 29 '22 at 15:45