You are not logged in.
When python in system path is 3.11, a venv is created and it works well.
After python in system path upgraded to 3.12, python in venv failed to work.
Recreating venv solve the problem.
The new problem is that python in venv takes several GB for the libraries,
recreating is expensive, any cheap way?
Last edited by jronald (2024-04-29 04:38:07)
Offline
I'll try to give an answer, but first what command did you use to create the venv originally?
Offline
I'll try to give an answer, but first what command did you use to create the venv originally?
I used the vscodium python plugin (ms-python) to create venv.
Offline
I don't normally use VS Code but I just had a look and it seems to use it's own custom implementation equivalent to `python -m venv` so if you want to keep using that then you have to delete the venv and recreate it via it's GUI. I don't actually think there is any other choice to rebuild venvs with a new base python other than delete + recreate but my suggestion is for people to migrate from `python -m venv` or `virtualenv` command line tools to the much better `uv` tool which is up to orders of magnitude faster than the older (venv + pip) tools and is a much better design. I anticipate VS Code (and other tools using venv and/or pip) will eventually migrate to uv also.
Offline
I don't normally use VS Code but I just had a look and it seems to use it's own custom implementation equivalent to `python -m venv` so if you want to keep using that then you have to delete the venv and recreate it via it's GUI. I don't actually think there is any other choice to rebuild venvs with a new base python other than delete + recreate but my suggestion is for people to migrate from `python -m venv` or `virtualenv` command line tools to the much better `uv` tool which is up to orders of magnitude faster than the older (venv + pip) tools and is a much better design. I anticipate VS Code (and other tools using venv and/or pip) will eventually migrate to uv also.
Thanks, it's quite helpful, I'll try.
Offline
BTW, you don't have to use that GUI within VS Code to create/maintain your venv. You can create it by hand in a terminal window, e.g. using uv venv + uv pip install, and then simply click on the Python button in the bottom right corner of VS Code and select that created venv/bin/python. VS Code will happily use that venv regardless of how it was created.
Offline
You can install 3.11 alongside 3.12 and relink the "python" file inside the "bin" folder in your venv directory to new python3.11 executable.
Offline
You can install 3.11 alongside 3.12 and relink the "python" file inside the "bin" folder in your venv directory to new python3.11 executable.
That won't suffice. You also have to rebuild all binary packages in the venv against the different python. I.e. pretty much the same as rebuilding it from scratch.
Offline