Files
the_information_nexus/tech_docs/linux/conda_install.md

3.7 KiB

Apologies for the oversight. Let me review the entire conversation and ensure that all the important items we've discussed are properly captured and documented in the guide.

Setting up Conda and JupyterLab on a Debian 12 Server

Prerequisites

  • A Debian 12 server
  • SSH access to the server
  • Basic command-line knowledge

Step 1: Update the System

sudo apt update && sudo apt upgrade

Step 2: Install Dependencies

sudo apt install wget gpg python3 python3-pip

Step 3: Download and Verify Miniconda

cd ~/Downloads
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh.sha256
sha256sum -c Miniconda3-latest-Linux-x86_64.sh.sha256

Step 4: Install Miniconda

bash Miniconda3-latest-Linux-x86_64.sh

During the installation, answer the prompts as follows:

  • Review the license agreement and enter "yes" to accept.
  • Press Enter to confirm the installation location or specify a custom location.
  • Enter "no" when asked to initialize Conda.

Step 5: Initialize Conda

eval "$(/home/medusa/miniconda3/bin/conda shell.bash hook)"
conda init
source ~/.bashrc
conda config --set auto_activate_base false

Step 6: Create and Activate a Conda Environment

conda create --name myenv python=3.12
conda activate myenv

Step 7: Install JupyterLab and Packages

python3 -m pip install --upgrade pip
python3 -m pip install jupyterlab numpy pandas matplotlib

Step 8: Configure JupyterLab for Remote Access

jupyter lab --generate-config
nano ~/.jupyter/jupyter_lab_config.py

Uncomment and modify the following lines:

c.ServerApp.ip = '0.0.0.0'  # Set to your server's IP or '0.0.0.0' for all interfaces
c.ServerApp.port = 8888  # Set to your desired port
c.ServerApp.open_browser = False

Step 9: Set a Password for JupyterLab

jupyter lab password

Step 10: Save and Use the Environment Configuration

A. Export the Environment Configuration

conda env export > environment.yml

B. Create a New Environment Using the Configuration File

conda env create -f environment.yml

C. Update an Existing Environment Using the Configuration File

conda env update --file environment.yml --prune

D. Share and Version Control the Configuration File

  • Store the environment.yml file in a GitHub repository along with your project files.
  • To recreate the environment on another machine, navigate to the directory containing the environment.yml file and run:
    conda env create -f environment.yml
    

E. Deactivate and Remove an Environment

  • To deactivate the current environment:
    conda deactivate
    
  • To remove an environment:
    conda env remove --name myenv
    

Step 11: Start JupyterLab

jupyter lab

Step 12: Access JupyterLab

Open a web browser on your local machine and navigate to http://your_server_ip:8888.

Step 13: Deactivate the Environment

conda deactivate

Additional Notes

  • Replace medusa with your actual username and myenv with your desired environment name.
  • Consider using SSH tunneling, a reverse proxy with SSL, or firewall rules for enhanced security.
  • If you need to make the conda command available in your shell after the Miniconda installation, run:
    eval "$(/home/medusa/miniconda3/bin/conda shell.bash hook)"
    

This guide includes all the essential steps and additional details such as saving and using the environment configuration file, sharing and version controlling the configuration file, deactivating and removing environments, and making the conda command available in the shell after installation.