Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default if I install virtualenv using pip and pip3 respectively?

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 ?

like image 739
Sniper_3B Avatar asked Aug 25 '15 04:08

Sniper_3B


People also ask

What is pip3 virtualenv?

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

Does pip install globally by default?

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 .

Is pip installed by default with Python?

pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.

What does pip3 install -- user do?

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.


1 Answers

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.

like image 82
holdenweb Avatar answered Oct 23 '22 04:10

holdenweb