This question already has an answer here:
I have created a virtual environment using python 3.6, then I've made a system upgrade and I've got python 3.7 installed system wide. Now I can't execute python files in that virtual environment because it's searching for python 3.6.
How can I upgrade the virtualenv python version to match the system wide version or how to downgrade the python version for that particular virtual environment?
I'm using manjaro.
See this link which explains it well.
Virtualenvwrapper comes with some convenient commands for managing your virtualenvs.
To change your Python version:
Deactivate your current environment session.
If you have many packages or libraries installed, it would be a good idea to make a requirements.txt file. Remember to edit version as necessary.
Remove the virtualenv with the wrapper command: rmvirtualenv
- This will remove the virtualenv, but leave your project files.
Make a new virtualenv with the Python version you want.
Example: mkvirtualenv -p python3 env-name
You can specify the Python version with the -p flag and version. If you have a requirements.txt file, you can specify that with -r requirements.txt
Now bind your new virtualenv to your project directory. You can specify the full paths, but it is easier to have your new virtualenv activated and be in your project directory. Then, run the command:
Example: setvirtualenvproject
Please let me/us know if this answer was helpful to you!
来源:https://stackoverflow.com/questions/51915484/how-to-change-the-python-version-of-already-existing-virtualenv