Managing packages and environments efficiently is crucial for data scientists and developers working on remote servers. Conda provides a robust solution for handling dependencies, making it an excellent choice for working on SSH servers.

This guide explains the step-by-step process of installing Conda on an SSH server, ensuring a smooth setup without the need for root access.

Prerequisites

Before beginning the installation, ensure the following:

  • Access to an SSH server
  • A stable internet connection
  • Basic knowledge of command-line operations

Step 1: Connect to the SSH Server

To begin, log into the SSH server using the command:

ssh username@server_address

Replace username with the appropriate username and server_address with the remote server’s address.

Step 2: Download the Miniconda Installer

Since Miniconda is a lightweight version of Anaconda, it is often preferred for installation on remote servers. Download it using wget:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

If installing on a different architecture, replace the URL with the appropriate version from the official Miniconda download page.

Step 3: Install Miniconda

Once downloaded, install Miniconda by running:

bash Miniconda3-latest-Linux-x86_64.sh

Follow the on-screen instructions:

  • Read and accept the license agreement.
  • Specify an installation directory (default is recommended).
  • Choose whether to initialize Conda automatically.

The installation may take a few minutes to complete.

Step 4: Activate Conda

After installation, activate Conda by running:

source ~/miniconda3/bin/activate

To verify that Conda is installed correctly, check the Conda version:

conda --version

If it outputs a version number, the installation was successful.

Step 5: Update Conda

Once installed, it is recommended to update Conda to ensure access to the latest features and security patches:

conda update -n base -c defaults conda

Step 6: Configure Conda for Use

Add Conda to PATH

If Conda was not initialized automatically, add it to the system’s PATH by modifying the .bashrc or .bash_profile file:

echo 'export PATH="~/miniconda3/bin:$PATH"' >> ~/.bashrc

Apply the changes:

source ~/.bashrc

Disable Conda Base Auto-Activation (Optional)

By default, Conda activates the base environment at every login. To disable this behavior:

conda config --set auto_activate_base false

Step 7: Create and Manage Environments

To create a new Conda environment with Python 3.9:

conda create --name my_env python=3.9

Activate the environment:

conda activate my_env

To list all available environments:

conda env list

To remove an environment:

conda remove --name my_env --all

Step 8: Install Packages

Use Conda to install packages within the environment:

conda install numpy pandas scikit-learn

To verify installed packages:

conda list

Conclusion

By following these steps, one can successfully install and configure Conda on an SSH server. This setup allows seamless management of dependencies and virtual environments, providing a streamlined workflow for research and development purposes.

FAQs

1. Can Conda be installed without root access?

Yes, Conda does not require root access. It installs in the user’s home directory, making it accessible without system-wide permissions.

2. What is the difference between Miniconda and Anaconda?

Miniconda is a minimal installation that includes Conda and essential dependencies, while Anaconda comes with a full suite of pre-installed packages for data science.

3. How can Conda environments be shared across multiple users on the same server?

By installing Conda in a shared directory and setting appropriate permissions, multiple users can access the same Conda installation.

4. How can Conda environments be exported and reinstalled?

To export an environment:

conda env export > environment.yml

To reinstall:

conda env create -f environment.yml

5. How to remove Conda from the server?

To uninstall Conda, remove the Miniconda directory and references from .bashrc:

rm -rf ~/miniconda3
sed -i '/miniconda3/d' ~/.bashrc

After following these steps, Conda will be completely removed from the system.

By Lawrence

Lawrencebros is a Technology Blog where we daily share about the Tech related stuff with you. Here we mainly cover Topics on Food, How To, Business, Finance and so many other articles which are related to Technology.

You cannot copy content of this page