Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between "virtualenv" and "-m venv" in creating Virtual environments(Python)

Sorry if I sound a bit foolish. I'm confused about this what's the difference between the two
virtualenv myvenv
and
-m venv myvenv
The first one works well for me in creating virtual environments while the other does not.
I CD into my development directory and use "virtualenv myvenv" and it creates the virtual environment. But if I use "-m venv myvenv" it just gives errors. Please help me understand

like image 958
Prince Kwekowe Avatar asked May 20 '17 23:05

Prince Kwekowe


People also ask

What is the difference between Python venv and virtualenv?

These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.

What is Python M venv?

The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories.

What do we mainly use venv or virtualenv for?

virtualenv is a tool for creating isolated Python environments containing their own copy of python , pip , and their own place to keep libraries installed from PyPI. It's designed to allow you to work on multiple projects with different dependencies at the same time on the same machine.

What is the difference between virtualenv and Virtualenvwrapper?

Virtualenvwrapper is a utility on top of virtualenv that adds a bunch of utilities that allow the environment folders to be created at a single place, instead of spreading around everywhere.


1 Answers

venv is a package shipped directly with python 3. So you don't need to pip install anything.

virtualenv instead is an independent library available at https://virtualenv.pypa.io/en/stable/ and can be install with pip.

They solve the same problem and work in a very similar manner.

If you use python3 I suggest to avoid an "extra" dependancy and just stick with venv

Your error is probably because you use Python2/pip2

like image 57
Costantin Avatar answered Sep 20 '22 13:09

Costantin