I have been using my python v3.9 in my virtual environment, it contains all the packages and scripts i have been using for so long. But, now with the release of python v 3.10 it installed itself globally though I wanted it to be installed in same venv I was using for python v3.9 So, if anyone could help me with how can I install python v3.10 in the same venv of my v3.9 . My IDE is PyCharm
CodePudding user response:
You can't.
You must create a 3.10 venv.
A virtual environment includes a copy of Python binaries. It can't be both 3.9 and 3.10.
What you can do is get a list of all libs in your 3.9 venv and instlal them in your 3.10 venv.
# In 3.9 venv
pip freeze > requirements.txt
# In 3.10 venv
pip install -r requirements.txt
CodePudding user response:
Simply put all the dependencies of your python 3.9 (venv) in requirements.txt file
pip freeze > requirements.txt
Create a new folder then move that file inside the newly created folder then execute the following code, it will create a new virtual environment with python 3.10
python -m venv newenv
activate the newly created environment by
source newenv/bin/activate
then install the required dependencies by
pip install -r requirements.txt
Note: If your OS do not have 'venv' module then simply install it by using
pip install venv