Skip to content

Instantly share code, notes, and snippets.

@thumbarnirmal
Last active November 21, 2022 18:51
Show Gist options
  • Save thumbarnirmal/25c6b232fe5a87c6eafc7da15b135210 to your computer and use it in GitHub Desktop.
Save thumbarnirmal/25c6b232fe5a87c6eafc7da15b135210 to your computer and use it in GitHub Desktop.
Commands for initial Python environment setup
# Install pip
sudo apt install python3-pip
# Install virtualenv using pip3
sudo pip3 install virtualenv
# Create a virtual environment
virtualenv venv
# Create virtual environment for a specific Python interpreter version
virtualenv -p /usr/bin/python2.7 venv
# Active virtual environment
source venv/bin/activate
# Deactivate virtual environment
deactivate
# To use virtual environment as a notebook kernel
# From inside the virtual environment
pip install ipykernel
ipython kernel install --user --name=kernel_name
# If the notebook doesn't pick up the new kernel, use this instead of the previous command
python3 -m ipykernel install --user --name=kernel_name
# To list available kernels in jupyter
jupyter kernelspec list
# To remove a specific kernel from jupyter
jupyter kernelspec remove kernel_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment