Tuesday, February 1, 2022

[SOLVED] Python virtualenv switch to 3.5 from 2.7

Issue

How can I switch from virtualenv that uses python 2.7 to python virtualenv that uses python 3.5?


id='dv4'>

Solution

Migration from 2.x to 3.x Python has nothing to do with virtualenv. If you already built your project keeping in mind a version change, then it will not be hard.

You can just download the Python35 and install it. After that, just execute

virtualenv -p /path to your Python35 directory/python.exe name_of_env

to create a new virtual environment for Python3.5. You can imagine the new virtual environment as a fresh Python installation with no third packages.


Please note that virtualenv just creates a new environment inside your computer with the Python version you specified in the -p parameter (or if omitted the Python version that is specified in your Path).

You can then install the desired packages for your project after activating the new virtual environment (./name_of_env/Scripts/activate) by executing pip install package_name


Although keep in mind that version migration is not the simplest thing. Many things can go wrong and especially the packages version support. Most of the packages support Python 3.x but not all of them.



Answered By - Skod
Answer Checked By - Katrina (WPSolving Volunteer)