Miniconda
In this article, I will introduce Miniconda to create a virtual development environment.
Miniconda is a very useful tool for developers. It is a repository management system without any packages. If you would like to use pre-shipped packages, you better choose Anaconda, a distribution with some common built in packages.
Package, dependency and environment management for any language—Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, FORTRAN — Conda Official Description
For my personal preference, I would choose Miniconda which provides a fresh and clean virtual environment for me to decide what packages should be installed. Some people may think that Miniconda is for Python, however, it is not true. For example, Nodejs can also be used with it. I will introduce the basic usage of Miniconda in the coming section. If you want to go deeper, you can check Conda — documentation
Installation
Before starting to use the miniconda, we have to go Miniconda — Conda to download and install the binary installer.
Enhance the Miniconda
After the installation, I recommend to install the following items to enhance Miniconda
A community driven packaging for conda.
Used for searching the updated package. It is used for replace the original official channel.
$ conda config --add channels conda-forge
anaconda Anaconda channel
$ conda config --add channels anaconda
conda-env Provides a unified interface to dealing with Conda environments. Used for managing the environment.
$ conda install -c conda conda-env
How to use
Create a fresh environment
To create a new virtual environment, use
$ conda create -p <name of env> python=3.6
A new folder will created in the current working directory.
Activate the virtual environment
At the same level of virtual environment directory, run
$ activate <environment name>
If you are use Mac or Linux based OS, you should use
$ bash activate <environment name>
or
$ source activate <environment name>
Install modules
Use Conda to install modules
$ conda install -n <name of env> <module name>
Use pip to install modules
$ pip install <module name>
Backup environment dependencies and installed packages
This section will make use of condo-env
Export Environment Config with Dependencies
$ conda env export -p <name of env> --no-builds > config.yml
Restore the backup environment from config file
Create Environment from config
$ conda env create -p <name of env> -f config.yml
Supplementary: Using miniconda with Nodejs
Besides Python, conda can help to create the Virtual Environment for nodejs. You can create it with
conda create -p nodejs -c conda-forge nodejs=8
Since default conda create -p nodejs nodejs only have version 6, but the latest LTS is 8
Last updated