Questions tagged [virtualenv]

virtualenv is a tool that creates sandboxed Python environments.

virtualenv allows you to create a sandboxed and isolated environment where Python packages can be installed without interfering with other packages on the same machine. With several virtualenvs, many different pieces of Python software with different and even mutually exclusive dependencies can live together.

The source code of this tool is hosted on GitHub.

Basic usage:

$ virtualenv ENV
$ source ENV/bin/activate
(ENV) $ easy_install (package)
(ENV) $ deactivate
$ ...

See the Command reference for a complete list of all available commands.

7398 questions
2467
votes
16 answers

How to leave/exit/deactivate a Python virtualenv

I'm using virtualenv and the virtualenvwrapper. I can switch between virtualenv's just fine using the workon command. me@mymachine:~$ workon env1 (env1)me@mymachine:~$ workon env2 (env2)me@mymachine:~$ workon env1 (env1)me@mymachine:~$ How do I…
Apreche
  • 30,042
  • 8
  • 41
  • 52
2016
votes
8 answers

What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?

Python 3.3 includes in its standard library the new package venv. What does it do, and how does it differ from all the other packages that match the regex (py)?(v|virtual|pip)?env?
Flimm
  • 136,138
  • 45
  • 251
  • 267
1732
votes
18 answers

How can I install packages using pip according to the requirements.txt file from a local directory?

Here is the problem: I have a requirements.txt file that looks like: BeautifulSoup==3.2.0 Django==1.3 Fabric==1.2.0 Jinja2==2.5.5 PyYAML==3.09 Pygments==1.4 SQLAlchemy==0.7.1 South==0.7.3 amqplib==0.6.1 anyjson==0.3 ... I have a local archive…
kakarukeys
  • 21,481
  • 10
  • 35
  • 48
1677
votes
41 answers

Use different Python version with virtualenv

How do I create a virtual environment for a specified version of Python?
Ulf
  • 17,492
  • 5
  • 19
  • 13
1187
votes
34 answers

How do I remove all packages installed by pip?

How do I uninstall all packages installed by pip from my currently activated virtual environment?
blueberryfields
  • 45,910
  • 28
  • 89
  • 168
893
votes
23 answers

How do I update/upgrade pip itself from inside my virtual environment?

I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. What's the command for that? Do I need to use…
zakdances
  • 22,285
  • 32
  • 102
  • 173
873
votes
23 answers

Using Python 3 in virtualenv

Using virtualenv, I run my projects with the default version of Python (2.7). On one project, I need to use Python 3.4. I used brew install python3 to install it on my Mac. Now, how do I create a virtualenv that uses the new version? e.g. sudo…
Prometheus
  • 32,405
  • 54
  • 166
  • 302
783
votes
22 answers

How do I remove/delete a virtualenv?

I created an environment with the following command: virtualenv venv --distribute Trying to remove it with the following command: rmvirtualenv venv does not work. I do an lson my current directory and I still see venv The only way I can remove it…
wulymammoth
  • 8,121
  • 4
  • 19
  • 19
725
votes
10 answers

Where does pip install its packages?

I activated a virtualenv which has pip installed. I did pip3 install Django==1.8 and Django successfully downloaded. Now, I want to open up the Django folder. Where is the folder located? Normally it would be in "downloads", but I'm not sure where…
SilentDev
  • 20,997
  • 28
  • 111
  • 214
702
votes
36 answers

How to install psycopg2 with "pip" on Python?

I'm using virtualenv and I need to install "psycopg2". I have done the following: pip install http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160 And I have the following…
André
  • 24,706
  • 43
  • 121
  • 178
639
votes
11 answers

How can I upgrade specific packages using pip and a requirements file?

I'm using pip with a requirements file, in a virtualenv, for my Django projects. I'm trying to upgrade some packages, notably Django itself, and I'm getting an error about source code conflicts: Source in /build/Django has version…
gcaprio
  • 6,447
  • 2
  • 17
  • 8
568
votes
38 answers

No module named pkg_resources

I'm deploying a Django app to a dev server and am hitting this error when I run pip install -r requirements.txt: Traceback (most recent call last): File "/var/www/mydir/virtualenvs/dev/bin/pip", line 5, in from pkg_resources import…
igniteflow
  • 8,404
  • 10
  • 38
  • 46
486
votes
19 answers

Determine if Python is running inside virtualenv

Is it possible to determine if the current script is running inside a virtualenv environment?
miracle2k
  • 29,597
  • 21
  • 65
  • 64
397
votes
8 answers

Is it bad to have my virtualenv directory inside my git repository?

I'm thinking about putting the virtualenv for a Django web app I am making inside my git repository for the app. It seems like an easy way to keep deploy's simple and easy. Is there any reason why I shouldn't do this?
Lyle Pratt
  • 5,636
  • 4
  • 27
  • 28
377
votes
9 answers

What is the purpose of "pip install --user ..."?

From pip install --help: --user Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full details.) The…
Rob Truxal
  • 5,856
  • 4
  • 22
  • 39
1
2 3
99 100