Ubuntu16.04部署python2和python3共存的Jupyter Notebook
一、安装python和python-pip
sudo apt-get install python python3 python-pip python3-pip sudo pip install --upgrade pip #更新pip sudo pip3 install --upgrade pip
sudo pip install jupyter
sudo pip3 install jupyter
三、配置可以同时使用python2和python3内核
sudo ipython kernel install--user sudo python3 -m ipykernel install--user sudo pip2 install -U ipykernel sudo python2 -m ipykernel install--user
四、添加到环境变量并运行
export PATH=$PATH:~/.local/bin #当前会话生效
sudo
jupyter-notebook 或者~/.local/bin/jupyter-notebook
#运行,会自动打开web界面,可以同时运行python2,python3,ctrl+c结束把export PATH=$PATH:~/.local/bin 添加到的最后一行 ~/.bashrc ,永久生效
五、其它设置
sudo jupyter-notebook password #设置密码
生成配置文件:
sudo jupyter notebook --generate-config
sudo vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '*' #访问ip限制 c.NotebookApp.notebook_dir = '/home/knmax/Desktop/Python/jupyter-project' #工作目录,路径不能出现中文 c.NotebookApp.open_browser = False #不自动打开浏览器 c.NotebookApp.port = 88 #运行监听的端口,默认是8888
启动时遇到的问题:
blue@blue-Box:~$ jupyter-notebook
jupyter-notebook: command not found
A:环境变量问题,参照第四步的配置
export PATH=$PATH:~/.local/bin
可以使用这个命令启动:~/.local/bin/jupyter-notebook
参考:
Ubuntu部署Jupyter - 黑夜浮屠 - 博客园
ubuntu - After installing with pip, "jupyter: command not found" - Stack Overflow