0x01 安装 python 依赖
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y
0x02 下载源码包并解压
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
xz -d Python-3.8.5.tar.xz
tar -xf Python-3.8.5.tar
0x03编译安装
./configure --prefix=/opt/python38/
make
make install
0x04 配置环境变量
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
变更为:
/opt/python38/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
添加一行
vim /etc/profile
PATH=/opt/python38/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
sourece /etc/profile
0x05 pip3 更换源
1、在用户根目录下 ~ 下创建 .pip 隐藏文件夹,
如果已经有了可以跳过
-- mkdir ~/.pip
2、进入 .pip 隐藏文件夹并创建 pip.conf
配置文件
-- cd ~/.pip && touch pip.conf
3、编辑pip.conf的内容如下
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
0x06 安装 jupyter
1. pip3 install ipython
pip3 install jupyter
2. ipython进入
from IPython.lib import passwd
passwd()#生成密码
3.jupyter notebook --generate-config --allow-root
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.open_browser = False
c.NotebookApp.password = 'sha1:4d75995b2f75:c08ada6f31047fe429d0b24652f8fbc81ec32a7c'
c.NotebookApp.port = 8000
4.jupyter notebook --allow-root #启动notebook
0则评论给“centos7 安装 python3.8”