3.4 KiB
3.4 KiB
Setting up Conda and JupyterLab on a Debian or Ubuntu
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
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.ymlfile in a GitHub repository along with your project files. - To recreate the environment on another machine, navigate to the directory containing the
environment.ymlfile 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
medusawith your actual username andmyenvwith 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
condacommand 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.