Downgrade venv interpreter
I have python 3.9 installed in my venv. I want to use 3.8 instead. I've installed 3.8 on Windows. If I configure the project to use this system interpreter instead of the 3.9 installed in the venv, I believe I will no longer be using the virtual environment. Is that correct? Can I install a new interpreter into the virtual environment and use that? I realise that packages that are already installed will have a dependency on the 3.9 interpreter and will need to be reinstalled against 3.8.
请先登录再写评论。
You can create new virtualenv by selecting python 3.8 as base:
> I realise that packages that are already installed will have a dependency on the 3.9 interpreter and will need to be reinstalled against 3.8
This is correct, you will need to reinstall the packages again for python 3.8
Thanks for your reply. I wanted to know if using the system interpreter would affect the venv in any way.
The current interpreter is inside the venv
If I use the system interpreter, it will be outside the venv.
I thought the idea of using a venv is that all components are kept within the venv. If it is not necessary to have the interpreter inside the venv, why was it copied to the venv\scripts directory when the venv was created? Why is the current interpreter not set to the system 3.9 interpreter?
Thanks for your help.
When you create a virtual environment based on a specific python version (e.g. 3.9), all the packages will be installed specifically for that version. If you want to have another environment with python 3.8, you'll have to:
1. Create a new venv based on python 3.8
2. Install all the packages you need. You cannot reuse the packages from another environment with another python version. (Technically, you can, but that's highly not recommended).
Also, system interpreter is it's own global environment, so you can install some packages for, say, python 3.8 globally, and then create a venv that would inherit those packages as well. But it cannot inherit packages from python 3.9, and vice versa.
I hope it's more clear now.