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
98
votes
2 answers

What's the difference between "virtualenv" and "-m venv" in creating Python Virtual environments

Sorry if I sound a bit foolish. I'm confused about this: What's the difference between the two: virtualenv myvenv and -m venv myvenv The first one works well for me in creating virtual environments while the other does not. I cd into my…
Prince Kwekowe
  • 993
  • 1
  • 6
  • 6
98
votes
18 answers

/usr/bin/python3: Error while finding spec for 'virtualenvwrapper.hook_loader' (: No module named 'virtualenvwrapper')

I'm trying to follow How To Serve Django Applications with uWSGI and Nginx on Ubuntu 14.04 and I'm failing at the very earlier stage, due to amount of output, I placed all related information into Pastebin.com - #1 paste tool since 2002!. the actual…
alexus
  • 7,256
  • 12
  • 44
  • 66
98
votes
8 answers

Calling IPython from a virtualenv

I understand that IPython is not virtualenv-aware and that the most logical solution to this is to install ipython in each virtualenv seperately using pip install ipython So far so good. One thing I noticed is that if the system-wide copy of…
Mo Sander
  • 1,303
  • 1
  • 10
  • 14
97
votes
2 answers

Virtualenv and source version control

I recently started a Django project and I quickly realized that virtualenv will be really useful for many reasons. I set up the virtualenv and my project, but now I wonder what file I should add to my source control (in my case, Mercurial). Should I…
Martin
  • 39,309
  • 62
  • 192
  • 278
93
votes
4 answers

What is a virtualenv, and why should I use one?

I am trying to install a Python package with this command pip install I'm getting permission errors and I'm not sure why. I could run it with sudo, but someone told me that was a bad idea, and I should use a virtualenv…
Kevin
  • 28,963
  • 9
  • 62
  • 81
91
votes
4 answers

Python - manually install package using virtualenv

I have a python program I want to install into my virtualenv - it's a zip package that I need to unzip and then run a setup.py program - but my question is more regarding how to get these unzipped files into my virtualenv so that the package gets…
Jamison
  • 2,218
  • 4
  • 27
  • 31
91
votes
16 answers

What is the official "preferred" way to install pip and virtualenv systemwide?

Is it this, which people seem to recommend most often: $ sudo apt-get install python-setuptools $ sudo easy_install pip $ sudo pip install virtualenv Or this, which I got from http://www.pip-installer.org/en/latest/installing.html: $ curl -O…
coffee-grinder
  • 26,940
  • 19
  • 56
  • 82
90
votes
7 answers

Activate python virtualenv in Dockerfile

I have a Dockerfile where I tried to activate python virtualenv so that, it should install all dependencies within this env. However, everything still gets installed globally. I used different approaches and none of them worked. I am also not…
igsm
  • 1,280
  • 2
  • 17
  • 19
90
votes
11 answers

Use virtualenv with Python with Visual Studio Code

I have a Python project and navigation/autocomplete work perfectly within files in the project. I want to specify a virtualenv so that navigation/autocomplete work with packages inside that virtualenv. I tried this in settings.py, but…
Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202
89
votes
5 answers

calling conda source activate from bash script

I'm trying to activate my conda env via a bash script. Even though the script runs fine and my PATH appears to be changed within the script, it's getting reset somehow after the script terminates. I can call source activate test from the cmd line…
matt_k
  • 4,139
  • 4
  • 27
  • 33
89
votes
26 answers

SSL backend error when using OpenSSL

I was trying to install pycurl in a virtualenv using pip and I got this error ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other) I read some documentation saying that "To fix this,…
helloworld2013
  • 3,094
  • 5
  • 19
  • 26
87
votes
4 answers

How do I use pytest with virtualenv?

I installed pytest into a virtual environment (using virtualenv) and am running it from that virtual environment, but it is not using the packages that I installed in that virtual environment. Instead, it is using the main system packages. (Using…
Henry Grantham
  • 1,025
  • 2
  • 8
  • 11
86
votes
19 answers

"Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

I'm attempting to make a website with a few others for the first time, and have run into a weird error when trying to use Django/Python/VirtualEnv. I've found solutions to this problem for other operating systems, such as Ubuntu, but can't find any…
Taygo0o
  • 861
  • 1
  • 6
  • 3
85
votes
1 answer

RuntimeError: The current NumPy installation fails to pass a sanity check due to a bug in the windows runtime

I am using Python 3.9 on Windows 10 version 2004 x64. PowerShell as Administrator. Python version: Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32 Install matplotlib error. pip install…
Vy Do
  • 46,709
  • 59
  • 215
  • 313
83
votes
21 answers

How to automatically activate virtualenvs when cd'ing into a directory

I have a bunch of projects in my ~/Documents. I work almost exclusively in python, so these are basically all python projects. Each one, e.g. ~/Documents/foo has its own virtualenv, ~/Documents/foo/venv (they're always called venv). Whenever I…
Alex Lenail
  • 12,992
  • 10
  • 47
  • 79