Quick start: How to use anaconda, miniconda & conda?
You've heard of conda, anaconda, miniconda, what are they? But what are relations between these three conda-tors? Do I have to install all of them? How to use them?
TL;DR: whole package.
anaconda = conda + python + 250 pre-installed packages.
Official: A downloadable, free, open-source, high-performance, and optimized Python and R distribution. Anaconda includes conda, conda-build, Python, and 250+ automatically installed, open-source scientific packages and their dependencies that have been tested to work well together, including SciPy, NumPy, and many others.
if you install the 'anaconda' package for an environment, by default it installs 250+ packages, mainly for data science development purpose. Packages include scipy, numpy, pandas, jupyter, xlwings, etc. Handy! Dependencies are taken care of, they work well together.
miniconda = conda + python + minimum dependencies
Official: A miniconda includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib, and a few others. Use the conda install command to install 7,500+ additional conda packages from the Anaconda repository.
To actually take advantage of anaconda/miniconda, it is recommended to setup an environment for a project. An environment contains python and packages required for your project. If you ever work with virtualenv in python, you are in good hands.
1. Let's create an environment first
My work requires python 3.8.1 and the newest anaconda set. I will name the environment py38 (No creativity at all.)
$ conda create -n py38 anaconda=2020.02 python=3.8.1
Right now, at the time of writing, python-3.8.2 does not work with anaconda-2020.02.
In case you want to stick to python 3.7.
$ conda create -n py37 anaconda=2020.02 python=3.7
What's conda?conda (https://conda.io) is a management tool. You use conda to install packages and manage environment(profile). By defaults, installs packages from anaconda repository.
What's anaconda?https://conda.io/projects/conda/en/latest/glossary.html#anaconda
TL;DR: whole package.
anaconda = conda + python + 250 pre-installed packages.
Official: A downloadable, free, open-source, high-performance, and optimized Python and R distribution. Anaconda includes conda, conda-build, Python, and 250+ automatically installed, open-source scientific packages and their dependencies that have been tested to work well together, including SciPy, NumPy, and many others.
What's miniconda?TL;DR: mini setup, just enough to get things going.
miniconda = conda + python + minimum dependencies
Official: A miniconda includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib, and a few others. Use the conda install command to install 7,500+ additional conda packages from the Anaconda repository.
How to use it?So now you know miniconda and anaconda is basically the same thing, except anaconda comes with bunch of packages pre-installed for 'base' environment.
To actually take advantage of anaconda/miniconda, it is recommended to setup an environment for a project. An environment contains python and packages required for your project. If you ever work with virtualenv in python, you are in good hands.
1. Let's create an environment first
My work requires python 3.8.1 and the newest anaconda set. I will name the environment py38 (No creativity at all.)
$ conda create -n py38 anaconda=2020.02 python=3.8.1
Right now, at the time of writing, python-3.8.2 does not work with anaconda-2020.02.
In case you want to stick to python 3.7.
$ conda create -n py37 anaconda=2020.02 python=3.7
or simply
2. You can list available environments
$ conda env list
3. To actually 'source' an environment
$ conda activate py38
(py38) user@My-Mac-mini ~ %
you will see "(py38)" in front of the command line, indicating you are in 'py38' environment.
(py38) user@My-Mac-mini ~ % python
Python 3.8.1 (default, Jan 8 2020, 16:15:59)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> print(pandas.__version__)
1.0.1
As you can see, python version is 3.8.1 with pandas installed.
4. You may want to switch between environments, just to test your project using different python version.
Turns out that the procedure is very simple, just like activating an environment.
(py38) user@My-Mac-mini ~ % conda activate py37
(py37) user@My-Mac-mini ~ % python --version
Python 3.7.6
5. Time passes, new version is released, how to update?
Say, you installed anaconda-2019.10 last year, and recently a new release (2020.02) is available! What should you do?
I, personally, only update anaconda and let the dependency work by itself. Unless you have an absolute need to update a certain package, you don't have to update.
Notice here, 'install' is used instead of 'update'.
$ conda create -n py38 anaconda=2019.10 (Created months ago)
$ conda install -n py38 anaconda=2020.02 -y
$ python -V
Python 3.7.7
6. Available python/anaconda version? Show me the list!
All commands are tested working on March 30, 2020.
$ conda create -n py37 anaconda=2020.02
2. You can list available environments
$ conda env list
3. To actually 'source' an environment
$ conda activate py38
(py38) user@My-Mac-mini ~ %
you will see "(py38)" in front of the command line, indicating you are in 'py38' environment.
(py38) user@My-Mac-mini ~ % python
Python 3.8.1 (default, Jan 8 2020, 16:15:59)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> print(pandas.__version__)
1.0.1
As you can see, python version is 3.8.1 with pandas installed.
4. You may want to switch between environments, just to test your project using different python version.
Turns out that the procedure is very simple, just like activating an environment.
(py38) user@My-Mac-mini ~ % conda activate py37
(py37) user@My-Mac-mini ~ % python --version
Python 3.7.6
5. Time passes, new version is released, how to update?
Say, you installed anaconda-2019.10 last year, and recently a new release (2020.02) is available! What should you do?
I, personally, only update anaconda and let the dependency work by itself. Unless you have an absolute need to update a certain package, you don't have to update.
Notice here, 'install' is used instead of 'update'.
$ conda create -n py38 anaconda=2019.10 (Created months ago)
$ conda install -n py38 anaconda=2020.02 -y
$ python -V
Python 3.7.7
6. Available python/anaconda version? Show me the list!
conda search --full-name python
conda search --full-name anaconda
7. shell auto activate?
7. shell auto activate?
do not auto activate conda environment
$ conda config --set auto_activate_base False
(default) activate conda upon start a shell
$ conda config --set auto_activate_base True
All commands are tested working on March 30, 2020.
Comments
Post a Comment