Comprehensive Guide to Installing and Managing Anaconda and Conda on Linux
This article provides a step‑by‑step tutorial on what Anaconda and Conda are, how to install Anaconda on Linux, manage Python environments, handle packages, configure mirror sources, use Miniconda, the graphical UI, and run Jupyter Notebook, while also discussing their pros and cons.
Anaconda is a Python distribution focused on data analysis that bundles over 190 scientific packages and the conda package manager, simplifying environment and dependency handling; the default Python version is 2.7 for Anaconda and 3.6 for Anaconda3.
Conda is an open‑source package and virtual‑environment manager that can install, update, and remove packages (including non‑Python ones) and create isolated environments for different Python versions.
Installation of Anaconda :
Download the desired installer, e.g. wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh , ensure bzip2 is installed ( yum install -y bzip2 ), then run the script with bash Anaconda3-5.2.0-Linux-x86_64.sh . Accept the default installation path (/root/anaconda3) and optionally add Anaconda to the PATH and skip VS Code installation.
After installation, add the bin directory to the system PATH by editing /etc/profile and adding export PATH=$PATH:/root/anaconda3/bin , then apply the change with source /etc/profile . If a previous Python build exists, rename it to avoid conflicts.
Conda environment management :
Create environments with specific Python versions, e.g. conda create -n python27 python=2.7 anaconda , conda create -n python36 python=3.6 , or conda create -n python37 python=3.7 . List environments with conda env list , activate with conda activate myvenv (or source activate myvenv on older versions), and deactivate with conda deactivate . Export an environment to environment.yml using conda env export > environment.yml and recreate it with conda env create -f environment.yml . Environments can be cloned, removed, or recreated as needed.
Package management :
Install packages with conda install scipy (optionally specifying a version or channel), remove them with conda remove package_name , update with conda update package_name , and list installed packages using conda list . Search for packages via conda search --full-name python or fuzzy search conda search jieba .
Mirror source configuration :
Because the default channels are overseas and slow, add domestic mirrors such as TUNA: conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ and conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ , then enable URL display with conda config --set show_channel_urls yes . Remove or replace channels with conda config --remove channels <URL> . Clear the index cache using conda clean -i if errors occur.
Handling unavailable packages :
If a package is not found, install it via pip ( conda install pip && pip install jieba ) or search for a suitable channel with anaconda search jieba and install from that channel, e.g. conda install -c conda-forge jieba . Alternatively, download the source tarball from PyPI and install manually with python setup.py install .
Miniconda is a lightweight alternative that only includes Python and conda; it can be installed from TUNA mirrors and used identically to Anaconda.
Graphical interface :
Anaconda Navigator provides a UI for creating, importing, and managing environments and packages on Windows and other platforms.
Jupyter Notebook :
Launch with jupyter notebook --allow-root (Linux) or via the Navigator (Windows). Configure remote access by generating a config file ( jupyter notebook --generate-config --allow-root ), editing ~/.jupyter/jupyter_notebook_config.py to set c.NotebookApp.ip = '*' and c.NotebookApp.open_browser = False , and setting a password with jupyter notebook password . Start the server in the background with nohup jupyter notebook --allow-root > jupyter.log 2>&1 & and access it via a web browser.
Advantages and disadvantages :
Pros: powerful, cross‑platform, supports Python 2/3, resolves dependencies automatically, offers a GUI, and includes many scientific packages. Cons: the full Anaconda distribution is large and can be slow due to remote mirrors; Miniconda mitigates size but requires manual package installation.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.