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
173
votes
20 answers

pyvenv-3.4 returned non-zero exit status 1

I'm in Kubuntu 14.04 , I want to create a virtualenv with python3.4. I did with python2.7 before in other folder. But when I try: pyvenv-3.4 venv I've got: Error: Command '['/home/fmr/projects/ave/venv/bin/python3.4', '-Im', 'ensurepip',…
kahonmlg
  • 3,839
  • 3
  • 17
  • 21
166
votes
24 answers

'virtualenv' won't activate on Windows

Essentially I cannot seem to activate my virtualenv environment which I create. I'm doing this inside of Windows PowerShell through using scripts\activate but I get an error message: "cannot be loaded because the execution of scripts is disabled…
SScode
  • 1,755
  • 3
  • 12
  • 10
165
votes
32 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
  • 4,036
  • 4
  • 21
  • 25
158
votes
19 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…
codyc4321
  • 9,014
  • 22
  • 92
  • 165
157
votes
13 answers

Is it possible to install another version of Python to Virtualenv?

I have a shared account in a web-hosting that has Python 2.4 installed, but my code is not compatible with 2.4. Is it possible to install Python 2.6 directly to Virtualenv? Note: I don´t have permission to install it in the shared server.
André
  • 24,706
  • 43
  • 121
  • 178
157
votes
25 answers

Where is virtualenvwrapper.sh after pip install?

I'm trying to setup virtualenvwrapper on OSX, and all the instructions and tutorials I've found tell me to add a source command to .profile, pointing towards virtualenvwrapper.sh. I've checked all the python and site-packages directories, and I…
zakdances
  • 22,285
  • 32
  • 102
  • 173
156
votes
11 answers

How do I install from a local cache with pip?

I install a lot of the same packages in different virtualenv environments. Is there a way that I can download a package once and then have pip install from a local cache? This would reduce download bandwidth and time.
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
156
votes
5 answers

How to enable a virtualenv in a systemd service unit?

I want to "activate" a virtualenv in a systemd service file. I would like to avoid having a shell process between the systemd process and the python interpreter. My current solution looks like this: [Unit] Description=fooservice After=syslog.target…
guettli
  • 25,042
  • 81
  • 346
  • 663
154
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,595
  • 2
  • 11
  • 7
153
votes
32 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
  • 7,481
  • 5
  • 38
  • 30
153
votes
15 answers

virtualenv --no-site-packages and pip still finding global packages?

I was under the impression that virtualenv --no-site-packages would create a completely separate and isolated Python environment, but it doesn't seem to. For example, I have python-django installed globally, but wish to create a virtualenv with a…
ianw
  • 1,904
  • 2
  • 12
  • 7
151
votes
26 answers

How to repeat last command in python interpreter shell?

How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don't work. They produce nonsensical characters. (ve)[kakarukeys@localhost ve]$ python Python 2.6.6 (r266:84292, Nov 15 2010, 21:48:32) [GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on…
kakarukeys
  • 21,481
  • 10
  • 35
  • 48
149
votes
10 answers

Can I move a virtualenv?

This question is not a duplicate. It pertains not just to renaming a virtual environment, but to actually moving it to a different directory, including, potentially, a different user's directory. This is not the same as merely renaming a virtual…
Nathan Basanese
  • 8,475
  • 10
  • 37
  • 66
149
votes
11 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
  • 5,038
  • 5
  • 30
  • 32
148
votes
8 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
  • 259,804
  • 351
  • 777
  • 1,080