云主机 添加安全组将juypyter端口暴露出去(端口与juypyter指定端口一直),通过公网ip加端口号进行访问
python版本3.6.8
[root@ecs-kc1-large-2-linux-20200825091713 ~]# python3
Python 3.6.8 (default, Nov 21 2019, 19:02:24)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
使用清华源下载(未修改配置文件临时生效)-i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip
在准备安装python3和pip3时,请先安装依赖环境:yum install -y libffi-devel,和 yum -y install libxml2-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 一定要先装!不然会出现如下例一连串连锁反应的bug
# wheel 本质上是一个zip 包格式,用于 python 模块的安装,它的出现是为了替代 Eggs
pip3 install wheel
# 如果不安装会报错:
# Using legacy ‘setup.py install‘ for cffi, since package ‘wheel‘ is not installed. (由于未安装软件包“ wheel”,因此将旧版“ setup.py install”用于cffi。)
# ---
yum -y install libffi-devel
# 如果不安装会报错(基本上就死这了):
# c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
# ---
# python3以后版本使用加上版本号,否者python-devel
yum -y install python36-devel
# 如果不安装会报错:
# c/_cffi_backend.c:2:10: fatal error: Python.h: No such file or directory (c / _cffi_backend.c:2:10:致命错误:Python.h:无此类文件或目录)
# error: command ‘gcc‘ failed with exit status 1 (错误:命令“ gcc”失败,退出状态为1) 排查:(通过在命令行键入gcc命令是存在的,是执行失败)
# 原因:系统中没有python.h的原因,是因为没有安装python的开发版,即Python-devel这个包
# ---
(官网安装使用的就是这个包)以然使用临时生效清华源下载 快
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple notebook
如果之前安装过显示目录功能的话,这一步骤可以跳过
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter_contrib_nbextensions
安装完之后需要配置 nbextension,注意配置的时候要确保已关闭 Jupyter Notebook
jupyter contrib nbextension install --user --skip-running-check
上面两个步骤都没报错后,启动 Jupyter Notebook,上面选项栏会出现 Nbextensions 的选项,点开 Nbextensions 的选项,并勾选 Hinterland, Jupyter Lab 中的自动补全功能, 按 Tab 键即可使用
# 设置Jupyter Notebook登陆密码
jupyter notebook password
# ---
# 启动Jupyter Notebook
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root
# ---
# list 列出当前正在运行的笔记本服务器。
# password 设置笔记本服务器的密码。
# --port= 笔记本服务器将监听的端口(默认值:8888)
# --ip= 笔记本服务器将监听的IP地址。(0.0.0.0所有地址)
# --allow-root 不建议以root身份运行。 使用--allow-root绕过。
# --no-browser 启动后不要在浏览器中打开笔记本。
# 启动 Jupyter Notebook,勾选设置
systemctl stop nftables
原文:https://www.cnblogs.com/hao-ran/p/13561213.html