How can I switch from virtualenv that uses python 2.7 to python virtualenv that uses python 3.5?
-
I do not think that this would be possible. Suppose you installed your package using `pip` or `setup.py` for python2.7. Then the installed packages will be places in `$VENV_DIR/lib/python2.7/sitepackages/`. Notice that these packages will not be available for python3.5 since it will look in `$VENV_DIR/lib/python3.5/sitepackages/`. – costrouc Jul 12 '17 at 20:11
-
1You create a *new* virtualenv with the appropriate version. – jonrsharpe Jul 12 '17 at 20:12
-
https://stackoverflow.com/questions/15102943/how-to-update-python check that link – hansTheFranz Jul 12 '17 at 20:12
1 Answers
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.

- 435
- 6
- 16