I'm working with virtualenv in a project that was initialised with python2.7 and now i want to change the python version of my project with python3.5 by default! Can anyobody help me !!!
Asked
Active
Viewed 201 times
0
-
You can create a new virtualenv with python 3.5 and move your files there. – Ejaz Mar 19 '20 at 07:51
-
what do you mean by default? – Chris Mar 19 '20 at 07:57
-
https://stackoverflow.com/search?q=%5Bvirtualenv%5D+change+python+version – phd Mar 19 '20 at 09:33
1 Answers
0
You can use this command:
mkvirtualenv -p python3 env-name
Detailed instruction 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
The source is here

AlexKh
- 546
- 2
- 9
- 20