Ubuntu 安装Jupyter Notebook 及远程问题+Jupyter notebook 选择指定虚拟环境

it2024-01-06  60

Ubuntu 安装Jupyter Notebook 及远程问题+Jupyter notebook 选择指定虚拟环境

1.Ubuntu 安装Jupyter Notebook 及远程问题

1.1.目前系统状态:Ubuntu16.04

已经安装好了anaconda 并创建了虚拟环境

1.2.安装jupyter

pip install jupyter

1.3.启动Jupyter

Jupyter notebook

1.4.设置jupyter notebook可远程访问

1.4.1生成一个notebook配置文件:

jupyter notebook –generate-config 可进入查看 cd ~/.jupyter/jupyter_notebook_config.py

1.4.2设置密码:

jupyter notebook password 会要求输入两次密码

1.4.3查看密码转换成sha1的密码:

Cat ~/.jupyter/jupyter_notebook_config.json 复制"sha1:和后面的一串密文"

1.4.4修改配置文件:

jupyter notebook –generate-config sudo gedit ~/.jupyter/jupyter_notebook_config.py 直接在第一行插入以下内容 c.NotebookApp.ip='10.132.224.31' c.NotebookApp.password = u"sha1: 和后面的一串密文" c.NotebookApp.open_browser = False c.NotebookApp.port = 8899 #可自行指定一个端口, 访问时使用该端口

1.4.5运行:

jupyter notebook 即可在其他电脑的浏览器中使用jupyter notebook

2.在jupyter notebook中使用指定的虚拟环境

2.1.为虚拟环境安装ipykernel包,比如我之前创建了一个名为tensorflow的虚拟环境,则

conda install -n tensorflow ipykernel

2.2.激活这个环境:

conda activate tensorflow

2.3.然后:

python -m ipykernel install --user --name tensorflow --display-name tf

最新回复(0)