wget https://www.python.org/ftp/python/3.7.11/Python-3.7.11.tgz
解压缩tar -zxvf https://www.python.org/ftp/python/3.7.11/Python-3.7.11.tgz -C 目标路径
安装C编译器yum install gcc
如果不安装,./configure会报错:configure: error: no acceptable C compiler found in $PATH
注意要加*,不能只安装zlib
yum install zlib*
zlib.i686 1.2.7-19.el7_9 updates
zlib-devel.i686 1.2.7-19.el7_9 updates
zlib-devel.x86_64 1.2.7-19.el7_9 updates
zlib-static.i686 1.2.7-19.el7_9 updates
zlib-static.x86_64
如果不安装,会报错:zipimport.ZipimportError: can’t decompress data; zlib not available
yum install -y openssl-devel
如果不安装,pip安装模块时会提示:the SSL module is not available
yum install libffi-devel
如果不安装,在启动jupyter notebook时会提示:ModuleNotFoundError: No module named ‘_ctypes’
yum install sqlite*
如果不安装,在启动jupyter notebook时会提示:ModuleNotFoundError: No module named ‘_sqlite3’
./configure
make && make install
python3.7 -m pip install --upgrade pip
安装Jupyterpip3.7 install jupyter
不必单独安装ipython(一个更好用的python shell,用ipython进入,支持代码补齐),安装jupyter时会一起安装。
[root@localhost ~]# jupyter notebook --generate-config Writing default config to: /root/.jupyter/jupyter_notebook_config.py [root@localhost ~]# ipython Python 3.7.11 (default, Nov 29 2021, 17:23:53) Type 'copyright', 'credits' or 'license' for more information IPython 7.30.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: # 这里输入的密码,之后在web登录notebook时要录入,可以直接回车不设置 Verify password: Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$OFZ4/FTP688J02UlsKXMUQ$HVi1TY981x4727hMXzAtTg' [2]+ 已停止 ipython [root@localhost ~]# vim /root/.jupyter/jupyter_notebook_config.py c.NotebookApp.ip = '*' #设置远程所有ip可访问 c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$OFZ4/FTP688J02UlsKXMUQ$HVi1TY981x4727hMXzAtTg'#把刚刚复制的密码粘 贴 c.NotebookApp.open_browser = False #关闭浏览器 c.NotebookApp.port = 9999 #选一个可用的端口关闭防火墙
systemctl stop firewalld
启动jupyter服务不建议以root身份运行。请使用 --allow-root 绕过。
jupyter notebook --allow-root
http://192.168.81.128:9999/
输入上面passwd()设定的密码



