Installation
We need to install some software first. Execute the following lines in your jail:
sudo pkg install python37 sudo pkg install py37-notebook sudo pkg install py37-pandas sudo pkg install py37-scikit-learn
We also need to install matplotlib. This can be achieved by running the following lines:
sudo pkg install pkgconf sudo pkg install png sudo pkg install freetype2 sudo python3.7 -m ensurepip sudo pip3.7 install --upgrade pip sudo pip3.7 install --upgrade setuptools sudo pip3.7 install matplotlib
Configuration
The notebook requires some configuration changes in order to make it work. First, we have to generate a password by running
ipython
and then enter the following (do not pick a sensitive password as it will be sent in plain text over the internet in a later step!):
In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: 'sha1:some_hashed_password' In [3]: exit
and then copy the sha1:some_password
string (it will look different depending on the password you chose). Then run
mkdir -p ~/.jupyter ee ~/.jupyter/jupyter_notebook_config.py
and enter the following lines (replace some_password
with your password):
c.NotebookApp.ip = '127.0.0.1' c.NotebookApp.password = u'sha1:some_hashed_password' c.NotebookApp.open_browser = False c.NotebookApp.allow_remote_access = True c.NotebookApp.notebook_dir = '/tmp' c.NotebookApp.port = 8080
Then run
sudo ee /usr/local/bin/run-jupyter-notebook
and insert the following lines:
#!/bin/sh export LD_LIBRARY_PATH=/usr/local/lib/gcc7 /usr/sbin/daemon -c -f /usr/local/bin/jupyter-notebook
Also make the file executable by running
sudo chmod +x /usr/local/bin/run-jupyter-notebook
We can finally start the notebook server by executing
run-jupyter-notebook
We also have to make sure that the program starts after rebooting. This can be achieved by adding an entry in the crontab:
sudo ee /etc/crontab
and then add the following line at the end
@reboot $USERNAME /usr/local/bin/run-jupyter-notebook
where you have to replace $USERNAME
with your own actual username.
Usage
After setting everything up we can finally start using Python notebooks. Simply point your browser to the following URL and log in with the password that you entered earlier:
http://$USERNAME.it.pointpark.edu:8080
Note that again you have to replace $USERNAME
with your actual username.
2 comments on “Python”