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].
$ 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".
$ source activate ve_name (ve_name)$
(ve_name)$ source deactivate $
$ 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)
$ 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)
$ conda update conda $ conda create -n py27 python=2.7 anacondaTo activate this environment, use:
$ source activate py27
discarding /Users/nikolai/anaconda/bin from PATH prepending /Users/nikolai/anaconda/envs/py27/bin to PATH
(p27)$To check the active environment, use:
(py27)$conda info -e
# conda environments: # py27 * /Users/nikolai/anaconda/envs/py27 root /Users/nikolai/anaconda
(py27)$To deactivate this environment, use:
(py27)$ source deactivate
discarding /Users/nikolais/anaconda/envs/py27/bin from PATH
$conda info -e
# conda environments: # py27 /Users/nikolai/anaconda/envs/py27 root * /Users/nikolai/anaconda
$
Note: On Windows to activate this environment, use:
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:
deactivate py27
Remark: For the native Python 3 creation of virtual environments check [12].
© Nikolai Shokhirev, 2012-2024
email: nikolai(dot)shokhirev(at)gmail(dot)com