How to Install Miniconda on Ubuntu and Manage Python Environments Efficiently
Learn step‑by‑step how to install Miniconda on Ubuntu, transfer the installer via WinSCP, configure the base environment, avoid common pitfalls, and use essential conda commands to create, activate, deactivate, and manage Python virtual environments and packages.
Introduction
This article explains how to install Miniconda on Ubuntu, why Miniconda is preferred over the larger Anaconda distribution, and how to use conda to manage Python environments.
Why use conda to create Python environments
Linux distributions often ship with Python 2, and upgrading to Python 3 can be cumbersome because the system Python cannot be removed. Conda allows you to create isolated Python 3 environments without affecting the system interpreter, and the pip inside the environment will not conflict with the system pip.
Download
Official download page:
https://docs.conda.io/en/latest/miniconda.htmlTransfer files between Windows and Linux with WinSCP
Instead of command‑line tools, the article recommends using the graphical WinSCP client to drag and drop files between a Windows PC and a Linux server.
Install WinSCP.
Open the program.
Connect to the Linux host and drag files to the desired location.
Install Miniconda
After transferring the Miniconda installer to the Linux machine, run: bash Miniconda3-latest-Linux-x86_64.sh Accept the license, choose the default installation path (press Enter), and allow the installer to initialize the environment and add it to .bashrc. When the installation finishes, refresh the shell with: source .bashrc Running conda should now display the conda help, confirming a successful installation.
Where Miniconda is installed
The default location is the user's home directory, so deleting everything with rm -rf * would remove Miniconda and require re‑installation.
The (base) environment prompt
After sourcing .bashrc, the shell prompt shows (base), indicating the base conda environment is active. To hide it, run:
conda deactivate conda config --set auto_activate_base falseThese commands deactivate the base environment and prevent it from being auto‑activated in new sessions.
Common conda commands
Basic commands (Linux and Windows):
# Show conda version
conda -V
# Update conda
conda update conda
# List environments
conda env list
# List installed packages
conda list
# Search for a package
conda search package_name
# Install a package
conda install package_name
# Install a specific version
conda install package_name=1.5.0
# Update a package
conda update package_name
# Remove a package
conda remove package_nameCreate a virtual environment
conda create --name <env_name> [python_version] [package_name]Parameters: env_name: name of the environment python_version: optional Python version package_name: optional initial packages
Examples:
# Create an environment named spider
conda create --name spider
# Create spider with Python 3.6
conda create --name spider python=3.6
# Create spider with requests and scrapy
conda create --name spider requests scrapy
# Create spider with Python 3.6 and requests
conda create --name spider python=3.6 requestsActivate a virtual environment
conda activate <env_name>Example:
conda activate spiderDeactivate a virtual environment
conda deactivateInstall third‑party packages
After activating the desired environment, install packages with pip (the pip inside the environment will be used):
Activate the environment: conda activate <env_name> Install the package:
pip install <package_name>Conclusion
The article first explains why conda is a convenient way to create isolated Python environments, then shows how to transfer the Miniconda installer with WinSCP, install Miniconda on Ubuntu, and use essential conda commands for environment and package management.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
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.
