Numerical experiments, Tips, Tricks and Gotchas
virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need. See e.g. these refetences [1], [2], [3]. virtualenvwrapper is a set of extensions to the virtualenv tool. [4].
Conda is an open source package management system and environment management system for installing multiple versions of software packages and their dependencies and switching easily between them [5]. It comes with Anaconda Python distribution [6].
Conda virtual environment commands slightly differ from virtualenv [7], [8], [9].
1 2 | $ conda create -n ve_name python=x.y anaconda $ |
This will install the Python version and all the associated anaconda packaged libraries at "path_to_your_anaconda_location/anaconda/envs/yourenvname".
1 2 | $ source activate ve_name (ve_name)$ |
1 2 | (ve_name)$ source deactivate $ |
1 | $ conda remove -n ve_name -all |
Conda provides easy switch between different versio of Python [10], [11].
1. Anaconda with Python 2 installed as a default (short instruction)
1 2 3 4 5 6 | $ conda update conda $ conda create -n py33 python=3.3 anaconda $ source activate py33 . . . (py33)$ source deactivate $ |
2. Anaconda with Python 3 installed (long instruction with output)
1 2 | $ conda update conda $ conda create -n py27 python=2.7 anaconda |
1 | $ source activate py27 |
discarding /Users/nikolai/anaconda/bin from PATH prepending /Users/nikolai/anaconda/envs/py27/bin to PATH
1 | (p27)$ |
1 | (py27)$conda info -e |
# conda environments: # py27 * /Users/nikolai/anaconda/envs/py27 root /Users/nikolai/anaconda
1 | (py27)$ |
1 | (py27)$ source deactivate |
discarding /Users/nikolais/anaconda/envs/py27/bin from PATH
1 | $conda info -e |
# conda environments: # py27 /Users/nikolai/anaconda/envs/py27 root * /Users/nikolai/anaconda
1 | $ |
Note: On Windows to activate this environment, use:
1 | activate py27 |
C:\Users\Dr._Nikolai>conda info -e # conda environments: # py27 C:\Anaconda3\envs\py27 root * C:\Anaconda3
Note: On Windows to deactivate this environment, use:
1 | deactivate py27 |
Remark: For the native Python 3 creation of virtual environments check [12].
© Nikolai Shokhirev, 2012-2025
email: nikolai(dot)shokhirev(at)gmail(dot)com