一.安装所需的环境
- 首先需要在ubuntu安装虚拟环境,点击链接即可查看如何在ubuntu中安装虚拟环境
1. 在虚拟环境中安装jupyter
(jiqistudy)> pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple/
2. 安装所需的python库
(jiqistudy)> pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/
(jiqistudy)> pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple/
(jiqistudy)> pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple/
(jiqistudy)> pip install sklearn -i https://pypi.tuna.tsinghua.edu.cn/simple/
3. 创建目标目录并进入
(jiqistudy)> mkdir algorithm
(jiqistudy)> cd algorithm
4. 启动jupyter notebook
(jiqistudy)> jupyter notebook
二、jupyter远程访问配置
1、生成配置文件(~/.jupyter/jupyter_notebook_config.py)
jupyter notebook --generate-config
2、生成密钥
jupyter notebook password # 自己造一个密码输入一确认一次
vim ~/.jupyter/jupyter_notebook_config.json
记下密钥,sha1:…
3、编辑配置文件
vim ~/.jupyter/jupyter_notebook_config.py
修改以下几项:
c.NotebookApp.ip='*' # 就是设置所有ip皆可访问
c.NotebookApp.password = u'sha1:03... # 刚才复制的那个密文'
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port =1234 #随便指定一个端口
设置端口后要在阿里云控制台把这个端口打开
在浏览器中输入:公网ip:刚刚指定的端口,输入密码,即可进入
注
:若出现错误
OSError: [Errno 99]Cannot assign requested address
解决方法修改/etc/hosts
首先获取本机内网ip和本机hostname
ifconfig # 获取本机内网ip
vi /etc/hostname # 获取hostname
进入/etc/hosts,添加上一行内容
内网ip hostname # 上面获取的那两个
启动:
启动jupyter notebook
(jiqistudy)> jupyter notebook
若出现如下错误,请参考:
1.workon: command not found处理方法
2.ubuntu安装matplotlib时报错处理
3.jupyter重启失败KernelRestarter: restart failed
4.pandas安装报错
版权声明:本文为qq_42092076原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。