服务器版本
Ubuntu18.04
安装过程
安装相关软件
安装pip
$ pip
Command 'pip' not found, but can be installed with:
sudo apt install python-pip
ubuntu@VM-0-3-ubuntu:~$ sudo apt install python-pip
安装ipython
~$ pip install ipython
IPython 7.0+ supports Python 3.5 and above.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.
提示需要时用Pythone3.3以上版本。
修改python链接为python3
ubuntu@VM-0-3-ubuntu:~$ sudo rm /usr/bin/python
ubuntu@VM-0-3-ubuntu:~$ sudo ln -s /usr/bin/python3 /usr/bin/python
ubuntu@VM-0-3-ubuntu:~$ python -V
Python 3.6.8
安装python3-pip
~$ sudo apt-get install python3-pip
~$ sudo pip3 install --upgrade pip
Installing collected packages: pip
Found existing installation: pip 9.0.1
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed pip-19.3.1
安装ipython
ubuntu@VM-0-3-ubuntu:~$ sudo pip install ipython
Installing collected packages: parso, jedi, pickleshare, wcwidth, prompt-toolkit, decorator, pygments, ipython-genutils, traitlets, backcall, ptyprocess, pexpect, ipython
Successfully installed backcall-0.1.0 decorator-4.4.1 ipython-7.9.0 ipython-genutils-0.2.0 jedi-0.15.1 parso-0.5.1 pexpect-4.7.0 pickleshare-0.7.5 prompt-toolkit-2.0.10 ptyprocess-0.6.0 pygments-2.4.2 traitlets-4.3.3 wcwidth-0.1.7
安装jupyter
ubuntu@VM-0-3-ubuntu:~$ sudo pip install jupyter
Successfully built tornado prometheus-client pandocfilters pyrsistent
Installing collected packages: jupyter-core, pyrsistent, more-itertools, zipp, importlib-metadata, jsonschema, nbformat, python-dateutil, tornado, pyzmq, jupyter-client, ipykernel, MarkupSafe, jinja2, terminado, Send2Trash, webencodings, bleach, pandocfilters, mistune, testpath, defusedxml, entrypoints, nbconvert, prometheus-client, notebook, widgetsnbextension, ipywidgets, jupyter-console, qtconsole, jupyter
Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 bleach-3.1.0 defusedxml-0.6.0 entrypoints-0.3 importlib-metadata-0.23 ipykernel-5.1.3 ipywidgets-7.5.1 jinja2-2.10.3 jsonschema-3.1.1 jupyter-1.0.0 jupyter-client-5.3.4 jupyter-console-6.0.0 jupyter-core-4.6.1 mistune-0.8.4 more-itertools-7.2.0 nbconvert-5.6.1 nbformat-4.4.0 notebook-6.0.2 pandocfilters-1.4.2 prometheus-client-0.7.1 pyrsistent-0.15.5 python-dateutil-2.8.1 pyzmq-18.1.0 qtconsole-4.5.5 terminado-0.8.2 testpath-0.4.4 tornado-6.0.3 webencodings-0.5.1 widgetsnbextension-3.5.1 zipp-0.6.0
生成配置文件
ubuntu@VM-0-3-ubuntu:~$ jupyter notebook --generate-config
Writing default config to: /home/ubuntu/.jupyter/jupyter_notebook_config.py
生成密码
ubuntu@VM-0-3-ubuntu:~$ jupyter notebook --generate-config
Writing default config to: /home/ubuntu/.jupyter/jupyter_notebook_config.py
ubuntu@VM-0-3-ubuntu:~$ ipython
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from notebook.auth import passwd In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:9985cd9e8652:f3d3ce68fd620a1b1fe8e0612bd24008a47f22e1'
In [3]: quit 注意:这里按照过程提示分别输入
from notebook.auth import passwd
passwd()
输入两次您的密码
这样就可以生成sha1了。
创建jupyter工作目录
ubuntu@VM-0-3-ubuntu:~$ mkdir -p jupyter-workplace
修改jupyter配置
在jupyter_notebook_config.py文件最后,加入下面几句。
ubuntu@VM-0-3-ubuntu:~$ vi .jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*' #允许访问的IP地址,设置为*代表允许任何客户端访问
c.NotebookApp.password = u'sha1:9985cd9e8652:f3d3ce68fd620a1b1fe8e0612bd24008a47f22e1'
c.NotebookApp.open_browser = False #True的话会自动弹出窗口
c.NotebookApp.port =9999 #可自行指定一个端口, 访问时使用该端口
c.NotebookApp.allow_remote_access = True #这个一定得设置,不然会报错
c.NotebookApp.notebook_dir = '/home/ubuntu/jupyter-workplace' # jupyter notebook打开目录
启动jupyter服务
ubuntu@VM-0-3-ubuntu:~$ jupyter notebook
[I 12:54:01.019 NotebookApp] Writing notebook server cookie secret to /home/ubuntu/.local/share/jupyter/runtime/notebook_cookie_secret
[W 12:54:01.274 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 12:54:01.279 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 12:54:01.279 NotebookApp] The Jupyter Notebook is running at:
[I 12:54:01.279 NotebookApp] http://VM-0-3-ubuntu:9999/
[I 12:54:01.279 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 12:54:24.631 NotebookApp] 302 GET / (119.123.198.87) 0.75ms
[I 12:54:24.673 NotebookApp] 302 GET /tree? (119.123.198.87) 1.37ms
[I 12:54:34.339 NotebookApp] 302 POST /login?next=%2Ftree%3F (119.123.198.87) 1.64ms
这样访问服务器对应的9999端口,即可。