I work in WSL Ubuntu. After instalation python3.13 dependencies from my previous projects stopped working. Venv with python 3.12 stopped activate in vscode interface. ErrorMessage:
An Invalid Python interpreter is selected, please try changing it to enable features such as IntelliSense, linting, and debugging. See output for more details regarding why the interpreter is invalid.
command "source venv/bin/activate" works but all libraries "could not be resolvedPylance". When I try reinstal I see error:
ModuleNotFoundError: No module named 'pip'
But pip installed in this venv. I can see it folders. init and main files etc. I have pip for python3.12 and I have -m venv for python 3.12. I can recreate this venv but why I can`t turn it on properly?
Tried reinstall venv and pip for python3.12. python3 -m ensurepip is ok:
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (24.0)
But python3.12 -m ensurepip
ensurepip is disabled in Debian/Ubuntu for the system python.
python3.12 -m pip --version is working also as python3.12 -m pip install and python3.12 -m pip --upgrade pip
I ran into the exact same problem after installing Python 3.13 on WSL. Suddenly, all my existing virtual environments (created with Python 3.12) broke in VSCode. I was getting the "Invalid Python interpreter" error, Pylance couldn't resolve any imports, and pip appeared to be missing—even though I could see it in the venv/bin
folder.
Here’s what fixed it for me:
First, check what your system python3
now points to:
python3 --version
which python3
In my case, it was now Python 3.13, which explains why stuff started breaking. Your virtual environment still points to the Python 3.12 binary internally, but VSCode (and maybe even pip) is trying to use 3.13 instead.
You can confirm that by looking at the pyvenv.cfg
file inside your venv:
cat venv/pyvenv.cfg
You should see something like:
home = /usr/bin/python3.12
If that's the case, then you just need to tell VSCode to use that exact interpreter. Open the command palette (Ctrl+Shift+P
) in VSCode, choose “Python: Select Interpreter”, and manually select the path to your virtualenv’s Python binary:
/path/to/your/venv/bin/python
Also, double-check the shebang in your pip script:
head -n 1 venv/bin/pip
If it says #!/usr/bin/python3
, that might now point to Python 3.13, which breaks the venv. You can fix this by rebuilding the venv with the correct Python version:
python3.12 -m venv --upgrade-deps venv
Or, if that doesn’t work cleanly:
rm -rf venv
python3.12 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
And yeah, ensurepip
being disabled for system Python is normal on Ubuntu. Just make sure you have the necessary packages installed:
sudo apt install python3.12-venv python3.12-distutils
Once I manually selected the right interpreter in VSCode and fixed the pip shebang, everything worked again—IntelliSense, linting, imports, etc. Hope that helps.