MrNineteen 2020-02-09
[TOC]
使用 $ which python2
, $ which python3
查看,一般会返回 /usr/bin/python2
, /usr/bin/python3
,如果没有,那么就用 $ sudo apt-get install python2
来安装
sudo apt-get install python-pip
安装python2版本的pip
sudo -H pip install --upgrade pip
更新pip
sudo apt-get install ipython
安装ipython
sudo apt-get install ipython-notebook
安装ipython
sudo -H pip install jupyter
使用pip安装jupyter
此时所有需要的包都安装完成了,如果是在本地使用jupyter,那么直接输入 $ jupyter notebook
,然后在浏览器中输入 localhost:8080
就可以正常使用了
$ jupyter notebook --generate-config
首先生成jupyter的配置文件,文件名为 jupyter_notebook_config.py
,存储于 ~/.jupyter
中
$ ipython
打开ipython进行密码设置,输入以下内容
12345 | In [1]: from notebook.auth import passwdIn [2]: passwd()Enter password:Verify password:Out[2]: 'sha1:67c9eXXX' |
$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
接下来在 jupyter_notebook_config.py
文件中添加如下信息:
1大专栏 jupyter serverv>2 3 4 5 6 7 8 9 10 | # Set options for certfile, ip, password, and toggle off# browser auto-openingc.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem' c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key' # Set ip to '*' to bind on all interfaces (ips) for the public serverc.NotebookApp.ip = '*' c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>' c.NotebookApp.open_browser = False # It is a good idea to set a known, fixed port for server accessc.NotebookApp.port = 9999 |
现在在非 .jupyter
目录运行 $ jupyter notebook
,得到如下信息表示jupyter server
已成功运行
123 | Copy/paste this URL into your browser when you connect for the first time, to login with a token: https://localhost:8080/?token=b5f5e11340dcbf4c2e2b0c9b105fc87d5140d575c457aac8 |
在浏览器上输入 https://<your server ip>:8080
即可看到jupyter server
的界面
sudo apt-get install python3-pip
安装python3版本的pipsudo python3 -m pip install ipykernel
python3 -m ipykernel install --user
安装python3的内核
到此,再次运行$ jupyter notebook
就可以同时使用puthon2和3了。