I used sudo pip install virtualenv
, then when I run virtualenv ENV
in a directory, I get a Python 2 virtual enviroment.
If I use 'pip3 install virtualenv' to install virtualenv again, will it override the previous installation of virtualenv, then when I run virtualenv ENV
, I get a Python 3 virtual enviroment? or will it install a new virtualenv in a different name like virtualenv3 in a different place ?
Overview. Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either).
If you're in an active virtual environment, then the command installs pip into that environment. Otherwise, it installs pip globally on your system. The --upgrade option ensures that the pip version is the same as the one declared in ensurepip .
pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.
The --user flag to pip install tells Pip to install packages in some specific directories within your home directory. This is a good way to have your own default Python environment that adds to the packages within your system directories, and therefore, does not affect the system Python installation.
You don't need to go to those lengths. You can use Python 2's virtualenv
to create a Python 3 virtual environment. Supposing you have Python 3's binary installed at /usr/local/bin/python3
then simply run
virtualenv -p /usr/local/bin/python3 ENV
and you will find that
source ENV/bin/activate
gives you the Python 3 environment you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With