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
130
votes
10 answers

Activate a virtualenv via fabric as deploy user

I want to run my fabric script locally, which will in turn, log into my server, switch user to deploy, activate the projects .virtualenv, which will change dir to the project and issue a git pull. def git_pull(): sudo('su deploy') # here i…
Thomas Schreiber
  • 1,818
  • 2
  • 14
  • 11
128
votes
7 answers

how to specify new environment location for conda create

the default location for packages is .conda folder in my home directory. however, on the server I am using, there is a very strict limit of how much space I can use, which basically avoids me from putting anything under my home directory. how can I…
linX
  • 1,381
  • 2
  • 10
  • 4
128
votes
14 answers

Vagrant Not Starting Up. User that created VM doesn't match current user

I was trying to start up my vagrant machine, so I navigated to the folder where my vagrantfile is, and used: vagrant up && vagrant ssh but I got the following error message: The VirtualBox VM was created with a user that doesn't match the …
Luke
  • 1,632
  • 2
  • 11
  • 26
126
votes
5 answers

Revert the `--no-site-packages` option with virtualenv

I have created a virtualenv using the --no-site-packages option and installed lots of libraries. Now I would like to revert the --no-site-packages option and use also the global packages. Can I do that without recreating the virtualenv? More…
Olivier Verdier
  • 41,410
  • 26
  • 94
  • 89
125
votes
6 answers

Can I install Python windows packages into virtualenvs?

Virtualenv is great: it lets me keep a number of distinct Python installations so that different projects' dependencies aren't all thrown together into a common pile. But if I want to install a package on Windows that's packaged as a .exe installer,…
Ned Batchelder
  • 323,515
  • 67
  • 518
  • 625
125
votes
3 answers

Difference between 'python setup.py install' and 'pip install'

I have an external package I want to install into my python virtualenv from a tar file. What is the best way to install the package? I've discovered 2 ways that can do it: Extract the tar file, then run python setup.py install inside of the…
user2125465
  • 1,305
  • 2
  • 10
  • 7
122
votes
5 answers

Where should virtualenvs be created?

I'm confused as to where I should put my virtualenvs. With my first django project, I created the project with the command django-admin.py startproject djangoproject I then cd'd into the djangoproject directory and ran the command virtualenv…
Jim
  • 11,270
  • 21
  • 86
  • 134
121
votes
14 answers

ImportError: No module named 'encodings'

I recently reinstalled ubuntu and did upgrade to 16.04 and cannot use python: $ python manage.py runserver Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME…
121
votes
9 answers

How to source virtualenv activate in a Bash script

How do you create a Bash script to activate a Python virtualenv? I have a directory structure like: .env bin activate ...other virtualenv files... src shell.sh ...my code... I can activate my virtualenv…
Cerin
  • 50,711
  • 81
  • 269
  • 459
120
votes
25 answers

How do I activate a virtualenv inside PyCharm's terminal?

I've set up PyCharm, created my virtualenv (either through the virtual env command, or directly in PyCharm) and activated that environment as my Interpreter. Everything is working just fine. However, if I open a terminal using "Tools, Open…
Chris Cogdon
  • 6,041
  • 5
  • 32
  • 29
118
votes
9 answers

How to run Spyder in virtual environment?

I have been using Spyder installed with with Anaconda distribution which uses Python 2.7 as default. Currently I need to set up a development virtual environment with Python 3.4. Top two suggestions after research online are: to set up virtual…
tomaskazemekas
  • 4,210
  • 4
  • 27
  • 31
117
votes
34 answers

pip installing in global site-packages instead of virtualenv

Using pip3 to install a package in a virtualenv causes the package to be installed in the global site-packages folder instead of the one in the virtualenv folder. Here's how I set up Python3 and virtualenv on OS X Mavericks (10.9.1): I installed…
ƘɌỈSƬƠƑ
  • 6,538
  • 7
  • 30
  • 56
116
votes
2 answers

Rename an environment with virtualenvwrapper

I have an environment called doors and I would like to rename it to django for the virtualenvwrapper. I've noticed that if I just rename the folder ~/.virtualenvs/doors to django, I can now call workon django, but the environment still says…
hobbes3
  • 22,472
  • 23
  • 78
  • 114
115
votes
6 answers

How do you set your pythonpath in an already-created virtualenv?

What file do I edit, and how? I created a virtual environment.
TIMEX
  • 217,272
  • 324
  • 727
  • 1,038
113
votes
24 answers

pyvenv not working because ensurepip is not available

I upgraded from ubuntu 14.04 to ubuntu 16.04 a few days ago. When I try to create a virtual env by using pyvenv .venv or python3 -m venv .venv There is an error: The virtual environment was not created successfully because ensurepip is…
Louis M
  • 3,124
  • 3
  • 16
  • 20