Skip to content

Instantly share code, notes, and snippets.

@hadim
Last active May 30, 2019 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadim/80371fce626e1a97c0b8e1b7287c7cd9 to your computer and use it in GitHub Desktop.
Save hadim/80371fce626e1a97c0b8e1b7287c7cd9 to your computer and use it in GitHub Desktop.

Python Conda Setup

The goal is to install a Python friendly environment on your computer. It works on Linux, Windows and OSX. The base environment will provide you the minimum to be able to start Jupyter and then we will use different Conda environments with all the necessary packages to do analysis. Those environments will then be available as kernels in Jupyter.

  • Install Anaconda or Miniconda.

    • Miniconda is a light version of Anaconda that provide less packages. If you pan to use Conda environments, I would recommend using it.
  • Open a terminal.

  • Activate the base Conda environment (also called root):

conda activate base
  • Add the conda forge channel to your installation. It provides a wide variety of conda packages not available in the default channel:
conda config --add channels conda-forge
conda config --set channel_priority strict
  • Install Jupyter server in your base environment:
conda install jupyterlab nodejs nb_conda_kernels
  • Create a new environment where you are going to install the packages needed for your analysis. Here we call the envirionment ws for workspace but you can name it differently:
conda create -n ws python
  • Activate your newly created environment:
conda activate ws
  • Install the Python kernel and some useful packages in it:
conda install ipykernel numpy scipy matplotlib scikit-image scikit-learn pandas
  • Now you can start Jupyter, create a new notebook and select the ws kernel.

More tips

  • To update all the packages in an environment you can run the following:
conda activate ws  # or whatever env you want
conda update --all
  • If you have a Conda environment file environment.yml with a list of packages in it, you can update your environment with:
conda activate ws  # or whatever env you want
conda env update -f environment.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment