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
123
votes
6 answers

Can existing virtualenv be upgraded gracefully?

I have a virtualenv created for Python 2.5 and want to "upgrade" it to Python 2.6. Here is how it was originally set up: virtualenv --no-site-packages -p python2.5 myenv I now run virtualenv in the same directory to upgrade: virtualenv…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
122
votes
4 answers

Where in a virtualenv does the custom code go?

What sort of directory structure should one follow when using virtualenv? For instance, if I were building a WSGI application and created a virtualenv called foobar I would start with a directory structure like: /foobar /bin {activate,…
Phillip B Oldham
  • 18,807
  • 20
  • 94
  • 134
122
votes
14 answers

bash: mkvirtualenv: command not found

After following the instructions on Doug Hellman's virtualenvwrapper post, I still could not fire up a test environment. [mpenning@tsunami ~]$ mkvirtualenv test -bash: mkvirtualenv: command not found [mpenning@tsunami ~]$ It should be noted that…
Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
118
votes
4 answers

Failed to activate virtualenv with pyenv

I run: pyenv activate new_app And I get: Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again. I am trying to follow this tutorial:…
Romulus
  • 1,534
  • 2
  • 11
  • 18
116
votes
11 answers

How can I make a list of installed packages in a certain virtualenv?

You can cd to YOUR_ENV/lib/pythonxx/site-packages/ and have a look, but is there any convenient ways? pip freeze list all the packages installed including the system environment's.
holys
  • 13,869
  • 15
  • 45
  • 50
111
votes
12 answers

How to avoid "Permission denied" when using pip with virtualenv

I attempt to deploy a Python package with pip in a virtual environment on an Ubuntu machine, but encounter a permission-related issue. For example: (TestVirtualEnv)test@testServer:~$ pip install markdown2 terminates by: error: could not create…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199
110
votes
15 answers

ModuleNotFoundError: No module named 'virtualenv.seed.embed.via_app_data' when I created new env by virtualenv

I was creating a new virtual environment on Ubuntu 20.04: $ virtualenv my_env But it gave an error: ModuleNotFoundError: No module named 'virtualenv.seed.embed.via_app_data' Other info: $ virtualenv --version virtualenv 20.0.17 from…
Tung Ng.
  • 1,241
  • 2
  • 8
  • 12
108
votes
12 answers

Pip install Matplotlib error with virtualenv

I am trying to install matplotlib in a new virtualenv. When I do: pip install matplotlib or pip install http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz I get this error: building…
Darwin Tech
  • 18,449
  • 38
  • 112
  • 187
106
votes
8 answers

How do I tell a Python script to use a particular version

How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that? Bonus: How would this affect a…
jesuis
  • 2,246
  • 3
  • 19
  • 17
105
votes
6 answers

Is it ok having both Anacondas 2.7 and 3.5 installed in the same time?

I am using currently Anaconda with Python 2.7, but I will need to use Python 3.5. Is it ok to have them installed both in the same time? Should I expect some problems? I am on a 64-bit Win8.
GileBrt
  • 1,830
  • 3
  • 20
  • 28
103
votes
24 answers

'virtualenv' is not recognized as an internal or external command, operable program or batch file

After I installed Python and Djangom, I'm trying to use virtualenv for django project purpose using virtualenv. I installed virtualenv using pip. pip install virtualenv # got install successfully When I tried to run it, I got the error…
ShivaGuntuku
  • 5,274
  • 6
  • 25
  • 37
102
votes
5 answers

How do I install an old version of Django on virtualenv?

I want to install some specific version of a package (in this case Django) inside the virtual environment. I can't figure it out. I'm on Windows XP, and I created the virtual environment successfully, and I'm able to run it, but how am I supposed to…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
101
votes
11 answers

How to install a package inside virtualenv?

I created a virtualenv with the following command. mkvirtualenv --distribute --system-site-packages "$1" After starting the virtualenv with workon, I type ipython. It prompts me WARNING: Attempting to work in a virtualenv. If you encounter…
user1424739
  • 11,937
  • 17
  • 63
  • 152
101
votes
19 answers

virtualenv in PowerShell?

There seems to be a problem when virtualenv is used in PowerShell. When I try to activate my environment in PowerShell like... env/scripts/activate .. nothing happens. (the shell prompt should have changed as well as the PATH env. variable .) I…
utku_karatas
  • 6,163
  • 4
  • 40
  • 52
98
votes
8 answers

What are the Python equivalents to Ruby's bundler / Perl's carton?

I know about virtualenv and pip. But these are a bit different from bundler/carton. For instance: pip writes the absolute path to shebang or activate script pip doesn't have the exec sub command (bundle exec bar) virtualenv copies the Python…
riywo
  • 1,378
  • 1
  • 11
  • 14