Skip to content

Instantly share code, notes, and snippets.

@Andre-Tan
Created October 7, 2023 18:50
Show Gist options
  • Save Andre-Tan/08143b57bc5f764a210f837b5f117a62 to your computer and use it in GitHub Desktop.
Save Andre-Tan/08143b57bc5f764a210f837b5f117a62 to your computer and use it in GitHub Desktop.
Steps to install fresh Miniconda for Jupyter Notebook, and how to use virtual environments
'
A pipeline to do fresh installation of Miniconda.
'
# Download and run the bash script to your intended version of miniconda. Here being latest for Linux OS.
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
# Install Jupyter & Extension so conda can use other virtual environments
conda install jupyter
conda install nb_conda_kernels
# Ensure nbextension is there
jupyter nbextension list
# Install jupyter_contrib_nbextensions. Note that you can enable all extensions in the package after these 2 lines.
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install
# Enable nbextensions through terminal/use this bash script as-is if these are the packages you want
jupyter nbextension enable codefolding/main
jupyter nbextension enable codefolding/edit
jupyter nbextension enable collapsible_headings/main
jupyter nbextension enable execute_time/ExecuteTime
jupyter nbextension enable toc2/main
# Create virtual environment using conda. Ipykernel is needed for nb_conda_kernels to detect environment.
conda create -n env_test python=3.9 pip ipykernel
# Install packages in the virtual environment. I still use pip for package installation.
conda activate env_test
pip install -r requirements.txt
# In case you need to save the environment packages as requirements.txt
pip list --format=freeze > requirements.txt
# In the root environment, run Jupyter Notebook and see env_test as one of the kernel options.
conda deactivate
jupyter notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment