Skip to content

Instantly share code, notes, and snippets.

@andfanilo
Last active November 13, 2020 09:25
Show Gist options
  • Save andfanilo/7187c0646485a2d05f47014f1fc767bd to your computer and use it in GitHub Desktop.
Save andfanilo/7187c0646485a2d05f47014f1fc767bd to your computer and use it in GitHub Desktop.
Jupyter things

Jupyter kernels for Jupyterhub

Ref

You can use your own conda environments within Jupyterhub as a Kernel. Make sure the library "ipykernel" is installed in your environment. If not, you will have to install it before you proceed : conda install ipykernel

# Activate your environment 
conda activate yourEnvName

# Add Kernel 
python -m ipykernel install --user --name yourEnvName --display-name "Python (yourEnvName)"

Note: This Kernel will be visible on jupyterhub only for your own user

To list kernels : jupyter kernelspec list

If you want to uninstall a kernel from jupyterhub : jupyter kernelspec remove yourEnvName

Note : Here you are only installing your environment from Jupyterhub. You are not removing you actual enviroment from conda.

Configure Jupyter through file

Ref

jupyter lab --generate-config
vi .jupyter/jupyter_notebook_config.py

Auto reload

%load_ext autoreload
%autoreload 2

If too lazy to create setup.py to load src

import sys
from pathlib import Path
sys.path.append(str(Path("../src").resolve()))

from data import test

import warnings
warnings.filterwarnings('ignore')

Configure Pandas display rows/columns

pd.options.display.max_rows = None
pd.options.display.max_columns = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment