Update tech_docs/linux/conda_install.md
This commit is contained in:
@@ -1,42 +1,40 @@
|
||||
Certainly! I'll review the entire conversation and compare it with the attached document to build out a comprehensive step-by-step guide for setting up Conda and JupyterLab on a Debian 12 server. I'll include the additional details we've discussed, such as saving the `environment.yml` file, not launching Conda by default, and other helpful items.
|
||||
|
||||
Here's the complete and refined guide:
|
||||
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
|
||||
|
||||
## Step 1: Update your system
|
||||
## Prerequisites
|
||||
- A Debian 12 server
|
||||
- SSH access to the server
|
||||
- Basic command-line knowledge
|
||||
|
||||
## Step 1: Update the System
|
||||
```bash
|
||||
sudo apt update && sudo apt upgrade
|
||||
```
|
||||
|
||||
## Step 2: Install required dependencies
|
||||
|
||||
## Step 2: Install Dependencies
|
||||
```bash
|
||||
sudo apt install wget gpg python3 python3-pip
|
||||
```
|
||||
|
||||
## Step 3: Download and verify the Miniconda installer
|
||||
|
||||
## Step 3: Download and Verify Miniconda
|
||||
```bash
|
||||
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 Miniconda3-latest-Linux-x86_64.sh
|
||||
cat Miniconda3-latest-Linux-x86_64.sh.sha256
|
||||
sha256sum -c Miniconda3-latest-Linux-x86_64.sh.sha256
|
||||
```
|
||||
|
||||
## Step 4: Install Miniconda
|
||||
|
||||
```bash
|
||||
chmod +x Miniconda3-latest-Linux-x86_64.sh
|
||||
./Miniconda3-latest-Linux-x86_64.sh
|
||||
bash Miniconda3-latest-Linux-x86_64.sh
|
||||
```
|
||||
|
||||
During the installation, when prompted to choose whether to initialize Conda, enter "no" to prevent Conda from automatically launching on shell startup.
|
||||
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
|
||||
|
||||
```bash
|
||||
eval "$(/home/medusa/miniconda3/bin/conda shell.bash hook)"
|
||||
conda init
|
||||
@@ -44,151 +42,88 @@ source ~/.bashrc
|
||||
conda config --set auto_activate_base false
|
||||
```
|
||||
|
||||
Replace `your_username` with your actual username.
|
||||
|
||||
The `conda config --set auto_activate_base false` command prevents Conda from automatically activating the base environment on shell startup.
|
||||
|
||||
## Step 6: Create a Conda environment
|
||||
|
||||
## Step 6: Create and Activate a Conda Environment
|
||||
```bash
|
||||
conda create --name myenv python=3.12
|
||||
conda activate myenv
|
||||
```
|
||||
|
||||
## Step 7: Install JupyterLab and other packages within the environment
|
||||
|
||||
## Step 7: Install JupyterLab and Packages
|
||||
```bash
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install jupyterlab numpy pandas matplotlib
|
||||
```
|
||||
|
||||
## Step 8: Configure JupyterLab for remote access
|
||||
|
||||
## Step 8: Configure JupyterLab for Remote Access
|
||||
```bash
|
||||
jupyter lab --generate-config
|
||||
nano ~/.jupyter/jupyter_lab_config.py
|
||||
```
|
||||
|
||||
Open the `jupyter_lab_config.py` file located in `~/.jupyter/` and uncomment the following lines, making sure to set your desired IP address and port:
|
||||
|
||||
Uncomment and modify the following lines:
|
||||
```python
|
||||
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
|
||||
|
||||
## Step 9: Set a Password for JupyterLab
|
||||
```bash
|
||||
jupyter lab password
|
||||
```
|
||||
|
||||
Sure! Here's a refactored version of the section on saving and using the environment configuration:
|
||||
|
||||
## Step 10: Save and Use the Environment Configuration
|
||||
|
||||
### A. Export the Environment Configuration
|
||||
```bash
|
||||
conda env export > environment.yml
|
||||
```
|
||||
|
||||
1. Activate your Conda environment:
|
||||
```bash
|
||||
conda activate myenv
|
||||
```
|
||||
### B. Create a New Environment Using the Configuration File
|
||||
```bash
|
||||
conda env create -f environment.yml
|
||||
```
|
||||
|
||||
2. Export the current environment's configuration to a file named `environment.yml`:
|
||||
```bash
|
||||
conda env export > environment.yml
|
||||
```
|
||||
### C. Update an Existing Environment Using the Configuration File
|
||||
```bash
|
||||
conda env update --file environment.yml --prune
|
||||
```
|
||||
|
||||
This command saves the list of packages and their versions to the `environment.yml` file in the current directory.
|
||||
|
||||
3. Verify that the `environment.yml` file was created:
|
||||
```bash
|
||||
ls
|
||||
cat environment.yml
|
||||
```
|
||||
|
||||
The `ls` command lists the files in the current directory, and `cat` displays the contents of the `environment.yml` file.
|
||||
|
||||
### B. Create a New Environment Using the `environment.yml` File
|
||||
|
||||
1. To create a new environment using the `environment.yml` file, use the following command:
|
||||
### 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:
|
||||
```bash
|
||||
conda env create -f environment.yml
|
||||
```
|
||||
|
||||
This command creates a new Conda environment with the same name as specified in the `environment.yml` file and installs all the packages listed in the file.
|
||||
|
||||
2. Activate the newly created environment:
|
||||
```bash
|
||||
conda activate myenv
|
||||
```
|
||||
|
||||
### C. Update an Existing Environment Using the `environment.yml` File
|
||||
|
||||
1. To update an existing environment to match the specifications in the `environment.yml` file, use the `--prune` option:
|
||||
```bash
|
||||
conda env update --file environment.yml --prune
|
||||
```
|
||||
|
||||
This command updates the existing environment, removing any packages that are not listed in the `environment.yml` file.
|
||||
|
||||
### D. Share and Version Control the `environment.yml` File
|
||||
|
||||
1. Store the `environment.yml` file in a GitHub repository along with your project files to version control your environment and make it easily accessible to others.
|
||||
|
||||
2. To recreate the environment on another machine or in a different location, navigate to the directory containing the `environment.yml` file and run the `conda env create` command as shown in Step B.
|
||||
|
||||
### E. Deactivate and Remove an Environment
|
||||
|
||||
1. To deactivate the current environment and return to the base environment, use the following command:
|
||||
- To deactivate the current environment:
|
||||
```bash
|
||||
conda deactivate
|
||||
```
|
||||
|
||||
2. To remove an environment and all its packages, use the following command:
|
||||
- To remove an environment:
|
||||
```bash
|
||||
conda env remove --name myenv
|
||||
```
|
||||
|
||||
Replace `myenv` with the name of the environment you want to remove.
|
||||
|
||||
By following these steps, you can easily export, create, update, share, and remove Conda environments using the `environment.yml` file. This file serves as a blueprint for your environment, ensuring reproducibility and portability across different machines and users.
|
||||
|
||||
Remember to replace `myenv` with the actual name of your environment throughout the process.
|
||||
|
||||
## Step 11: Start JupyterLab
|
||||
|
||||
```bash
|
||||
jupyter lab
|
||||
```
|
||||
|
||||
## Step 12: Access JupyterLab
|
||||
Open a web browser on your local machine and navigate to `http://your_server_ip:8888`.
|
||||
|
||||
From your local machine, open a web browser and navigate to `http://your_server_ip:8888`. Replace `your_server_ip` with your server's IP address or hostname, and `8888` with the port you configured in step 8 if you changed it.
|
||||
|
||||
## Step 13: Deactivate the environment when done
|
||||
|
||||
## Step 13: Deactivate the Environment
|
||||
```bash
|
||||
conda deactivate
|
||||
```
|
||||
|
||||
## Additional Notes
|
||||
|
||||
- To recreate the environment on another machine or share it with others, use the `environment.yml` file:
|
||||
|
||||
```bash
|
||||
conda env create -f environment.yml
|
||||
```
|
||||
|
||||
- For added security, consider using SSH tunneling, configuring a reverse proxy with SSL encryption, or employing firewall rules to restrict access to your JupyterLab instance.
|
||||
|
||||
- Remember to replace `myenv` with your desired environment name and adjust the Python version and package list according to your requirements.
|
||||
|
||||
- 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:
|
||||
|
||||
```bash
|
||||
eval "$(/home/medusa/miniconda3/bin/conda shell.bash hook)"
|
||||
```
|
||||
|
||||
Replace `medusa` with your actual username.
|
||||
|
||||
This comprehensive guide includes all the necessary steps to set up Conda and JupyterLab on a Debian 12 server, along with additional details on saving the environment configuration, not launching Conda by default, and other helpful tips. You can store this guide on GitHub as a reference for future use.
|
||||
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.
|
||||
Reference in New Issue
Block a user