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.

A virtualenv can also be set up to completely ignore the system's site-packages, to ensure that all dependencies are installed within the sandboxed environment.

$ virtualenv ENV --no-site-packages
6571 questions
1882
votes
14 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
  • 23,946
  • 8
  • 37
  • 46
1400
votes
6 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 seem to match the regex (py)?(v|virtual|pip)?env?
Flimm
  • 97,949
  • 30
  • 201
  • 217
1288
votes
35 answers

Use different Python version with virtualenv

I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtualenv with a different version of Python? I compiled Python 2.6.2 and would…
Ulf
  • 13,582
  • 5
  • 17
  • 13
1273
votes
12 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
  • 16,427
  • 9
  • 28
  • 42
815
votes
22 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
  • 27,277
  • 37
  • 139
  • 270
620
votes
17 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
  • 16,715
  • 30
  • 94
  • 155
562
votes
33 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é
  • 21,421
  • 41
  • 110
  • 172
501
votes
10 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
  • 5,067
  • 2
  • 14
  • 8
487
votes
35 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
  • 7,356
  • 9
  • 35
  • 44
442
votes
7 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
  • 15,207
  • 26
  • 87
  • 180
358
votes
4 answers

Comprehensive beginner's virtualenv tutorial?

I've been hearing the buzz about virtualenv lately, and I'm interested. But all I've heard is a smattering of praise, and don't have a clear understanding of what it is or how to use it. I'm looking for (ideally) a follow-along tutorial that can…
Dan Burton
  • 51,332
  • 25
  • 109
  • 190
321
votes
9 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
  • 4,808
  • 3
  • 24
  • 26
317
votes
15 answers

Determine if Python is running inside virtualenv

Is it possible to determine if the current script is running inside a virtualenv environment?
miracle2k
  • 22,364
  • 17
  • 60
  • 62
282
votes
17 answers

How to activate virtualenv?

I have been through search and tried various alternatives without success and spent several days on it now - driving me mad. Running on Red Hat Linux with Python 2.5.2 Began using most recent Virtualenv but could not activate it, I found somewhere…
larry
  • 2,829
  • 2
  • 11
  • 5
278
votes
11 answers

Python: No acceptable C compiler found in $PATH when installing python

I'm trying to install new python environment on my shared hosting. I follow the steps written in this post: mkdir ~/src wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz tar -zxvf Python-2.7.1.tar.gz cd Python-2.7.1 mkdir…
mik.ro
  • 3,381
  • 2
  • 15
  • 22
1
2 3
99 100