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 !!!
- You can create a new virtualenv with python 3.5 and move your files there.Ejaz– Ejaz2020-03-19 07:51:04 +00:00Commented Mar 19, 2020 at 7:51
- what do you mean by default?Chris– Chris2020-03-19 07:57:44 +00:00Commented Mar 19, 2020 at 7:57
- stackoverflow.com/…phd– phd2020-03-19 09:33:26 +00:00Commented Mar 19, 2020 at 9:33
Add a comment |
1 Answer
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
1 Comment
ChrisBonheur
Thanks for your answer it worked well !!! :-)