0

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 !!!

3
  • You can create a new virtualenv with python 3.5 and move your files there. Commented Mar 19, 2020 at 7:51
  • what do you mean by default? Commented Mar 19, 2020 at 7:57
  • stackoverflow.com/… Commented Mar 19, 2020 at 9:33

1 Answer 1

0

You can use this command:

mkvirtualenv -p python3 env-name 

Detailed instruction to change your Python version:

  1. Deactivate your current environment session.
  2. 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.
  3. Remove the virtualenv with the wrapper command: rmvirtualenv

This will remove the virtualenv, but leave your project files.

  1. 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

  1. 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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer it worked well !!! :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.