Linux快速安装jupyter notebook&添加conda虚拟环境

安装jupyter notebook

输入命令安装jupyter notebook

pip3 install jupyter

安装后先生成配置文件,用于后面写入ip,端口号,密码等

jupyter notebook --generate-config

配置文件

启动【ipython】配置密码(注意不是python)

ipython
In [1]: from notebook.auth import passwd      #导入包
In [2]: passwd()                              #调用包
Enter password:                              #输入密码,用于后面登陆jupyter notebook
Verify password:                              #确认密码
Out[2]: 'sha1:ce23d945972f:34769685a7ccd3d08c84a18c63968a41f1140274'  #这段是密钥,复制下来等会用
exit() #退出

开始编辑配置文件

vim jupyter_notebook_config.py
#在任意地方加上如下内容(键入i进入插入模式)
c.NotebookApp.ip = '*'  #允许任何ip去访问我们的jupyter notebook
c.NotebookApp.password = u'sha1:ce23d945972f:34769685a7ccd3d08c84a18c63968a41f1140274'  #u后面加上你复制的密钥
c.NotebookApp.open_browser = False    #因为是在linux,就不让他打开浏览器了
c.NotebookApp.port = 8888    #随便指定一个端口,如果这个端口被占用,jupyter会加1重新找端口,直到找到为止
c.NotebookApp.allow_remote_access = True  #允许远程控制
c.NotebookApp.notebook_dir = u'路径'  #设置你打开jupyter notebook的时候想显示的位置,可以设置成经常使用的路径
#配置完记得保存(键入esc,然后输入:wq保存并退出)

启动jupyter notebook

jupyter notebook

在windows下远程访问jupyter notebook,在本地打开浏览器访问以下地址:

http://address_of_remote:8888

ps:需要注意的是,在哪个conda的虚拟环境中启动jupyter notebook,对应的kernel就是哪个虚拟环境;另外,py文件在jupyter notebook是无法运行的,需要新建一个ipynb文件,才有运行的按钮~

添加conda虚拟环境(选做)

如果发现conda虚拟环境无法生效,可以尝试执行以下命令:

conda install ipykernel
python3 -m ipykernel install --user --name myconda --display-name myconda

其中myconda为你的conda环境名字

你可能感兴趣的:(ubuntu,Python,Anaconda,linux,jupyter,python)