Skip to content

Instantly share code, notes, and snippets.

@branning
Last active October 27, 2017 15:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save branning/430f3e31cf9e25e95e0228c211da5693 to your computer and use it in GitHub Desktop.
Save branning/430f3e31cf9e25e95e0228c211da5693 to your computer and use it in GitHub Desktop.
Run Python 2 & 3 in Jupyter on Fedora Linux
#!/bin/bash
#
# Install Jupyter Notebook with Python 2 and Python 3 kernels on Debian
# from http://stackoverflow.com/a/34421527/347567
set -o errexit
# As root, install `pip` and `jupyter` from apt, and the development packages, too.
apt-get update
apt-get install -y \
python-pip \
python-dev \
python3-pip \
python3-dev
pip3 install jupyter
# Add the kernel for Python2 using the `ipykernel` module. The Python3 kernel is installed, already.
apt-get install -y libzmq3-dev # we don't want to build libzmq3, takes a while
pip install ipykernel
python2 -m ipykernel install
# Let's just start the party already!
[ -f run_jupyter.sh ] && bash run_jupyter.sh
#!/bin/bash
#
# Install Python 2 and Python 3 kernels for Jupyter on Fedora
# from http://stackoverflow.com/a/34447744/347567
# exit immediately if an error occurs
set -o errexit
dnf groupinstall 'Development Tools' -y
dnf install gcc-c++ -y
dnf install rpm-build -y
dnf install python-devel -y
dnf install python3-devel -y
dnf install python-pip -y
dnf install python3-pip -y
#pip install jupyter
pip3 install jupyter
python2 -m pip install ipykernel
python2 -m ipykernel install
# Let's just start the party already!
[ -f run_jupyter.sh ] && bash run_jupyter.sh
#!/bin/bash
#
# Run Jupyter on public port 8888
IP=`curl -s http://whatismyip.akamai.com/`
PORT=8888
# Open port 8888, if not opened
iptables -nL | grep $PORT >/dev/null || \
echo "Opening port $PORT" && \
iptables -A INPUT -p tcp --dport $PORT -j ACCEPT
jupyter notebook --ip=$IP --port=$PORT
# Close port 8888 when we're done
echo "Closing port $PORT"
RULE=`iptables -nL --line-numbers | grep $PORT | cut -d' ' -f1`
iptables -D INPUT $RULE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment