Linux remote Ipython notebook
Ipython Notebook has now been renamed Ipython Jupyter, the most well-known and best used Python data analysis tool.
Here's how to install Ipython Jupyter under Linux and remote access, where I configure Ipython,windows to access Ipython jupyter in virtual machines. 1. Install Anaconda
Anaconda is currently the best distribution for Python data analysis, integrating a number of commonly used data analysis modules, if you install the Python environment, a lot of holes.
Installation under Linux is also very simple, upload anaconda.sh to Linux, execute bash anaconda.sh, install it as prompted, and the last one asks if you want to add Python to the environment variable, choose Yes, and you can add it to bash manually after installation.
The following installation of the. BASHRC added Python environment variables:
# Added by Anaconda3 4.2.0 installer
export path= "/home/zhenyu/anaconda3/bin: $PATH"
2. Configure Ipython Jupyter
2.1. Generate Configuration file
# Generate Profile
Jupyter notebook--generate-config
# At this time the configuration file is generated:
# writing Default Config to:/home/zhenyu/.jupyter/ jupyter_notebook_config.py
# Create login Password
# Open Ipython, generate key
$ ipython from
notebook.auth import passwd
passwd ()
Enter password:
Verify password:
out[2]: ' Sha1:6f6193fcfbd5 : 614c4ba185334868fc8bbce2e9890b3ef7d1a79b '
# The password I created here is 123456, the corresponding key is the sha1xxxx of the string
# then Exit Ipython
2.2. Create a self-signed certificate
Use OpenSSL to create a self-signed certificate, because it is self-signed so the browser prompts a warning, select Trust exception can be. If you do not want to cause a warning, you need to have a certificate compliant certificate, reference [http://arstechnica.com/security/2009/12/ How-to-get-set-with-a-secure-sertificate-for-free/]
If it is intranet access does not worry about security issues, do not use SSL faster.
#
run under Linux, meet the query where you can return to
OpenSSL req-x509-nodes-days 365-newkey rsa:1024-keyout mycert.pem-out MYCERT.P EM
# will generate MYCERT.PEM under the current folder, I'll move it under the. Jupyter/secret folder for easy Management
# first create the. Secret folder
CD. Jupyter
mkdir Secret
# Mobile
CD ~
mv Mycert.pem. jupyter/secret/
2.3. Modify the configuration file
# Open the. jupyter/jupyter_notebook_config.py you just created, back up the source file, and then modify
# Backup
$ CP. jupyter/jupyter_notebook_config.py. Jupyter/jupyter_notebook_config.py_bak
# Modified as follows, you can delete the contents of the Add, can be modified, or directly in the head to add, anyway, the original contents are commented out:
vi/home/ zhenyu/.jupyter/jupyter_notebook_config.py
C = get_config ()
# Kernel config
c.ipkernelapp.pylab = ' Inline ' # If you want plotting support always
= ' * ' # is to set all IP accessible, in 144 line
C. Notebookapp.open_browser = False # Disables the automatic opening
of the browser # key, at 194 lines. The key is the 2.1-step generated
C.notebookapp.password = ' sha1:74d233d59da1:50d7ef60a58456e2016dc427547fb42cdd971cea '
c. Notebookapp.port = 6789 # Access port, in 197 line
# self-signed certificate location, if SSL is not used, you can not set
C.notebooknotary.secret_file = '/home/ Zhenyu/.jupyter/secret/mycert.pem '
c.notebookapp.keyfile = '/home/zhenyu/.jupyter/.secret/mykey.key '
# Set up the directory to store the created Ipython notebook file
c.notebookapp.notebook_dir = '/home/zhenyu/ipython '
3. Firewall Open Port
After starting Jupyter notebook, opening the browser in the virtual machine can be accessed Ipython jupyter, but remote is unreachable because of the firewall.
#
Open 6789 port
/sbin/iptables-i input-p TCP--dport 6789-j ACCEPT
save
/etc/rc.d/init.d/with root user su # Iptables Save Restart
service
iptables restart
4. Remote Access
# start Ipython jupyter, do not use SSL
Jupyter notebook
# or turn on SSL
# Jupyter notebook--certfile=mycert.pem--keyfile Mykey.key
jupyter Notebook--certfile=/home/zhenyu/.jupyter/secret/mycert.pem
# output, look at the last line, this time Jupyter Notebook can accept any IP access.
[I 12:55:05.929 Notebookapp] [nb_conda_kernels] enabled, 2 kernels found
[W 12:55:05.960 Notebookapp] Warning:the notebook server is listening to all IP addresses and not using encryption. This isn't recommended.
[I 12:55:06.078 Notebookapp] The Jupyter notebook is running At:http://[all IP addresses on your system]:6789/
You can access the Ipython notebook in the virtual machine by opening the browser input http://192.168.138.130:6789/. 5. Logs and background processes
The above boot way, will generate a log file in the current directory, I forgot to call the above name, in short, with Jupyter notebook run, log files will become larger, if not very important, you can set the log, the method is to redirect all output to/dev/null 2 >&1 &
In addition, the above boot mode is to start a foreground process, if the SSH connection is disconnected, Jupyter notebook is also invalid, so you need to jupyter notebook as a background process to start, in Linux is Nohup command.
# Do not start SSL, log output is not logged, as a background process to start Jupyter notebook
nohup jupyter notebook >/dev/null 2>&1 &
6. Stop Jupyter Notebook
Jupyter notebook As the background process starts, if you want to stop it, you can find the process ID first and then kill.
# view process
Ps-ef | grep ' Jupyter notebook '
# output is as follows, where 21983 is the process ID,
# hadoop 22136 21983 0 09:10 pts/ 1 00:00:00 grep jupyter notebook
# Kill process
kill-9 21983
# This time the browser can no longer connect jupyter notebook.
Reference
Http://jupyter-notebook.readthedocs.io/en/latest/public_server.html
Http://www.cnblogs.com/zhanglianbo/p /6109939.html
http://blog.csdn.net/gavin_john/article/details/53177630
http://jingyan.baidu.com/article/ 335530daa4707f19cb41c3ef.html