在 CentOS 上装 Python 本身并不慢,但很多人觉得“慢”,通常是因为以下几个原因:
用 yum 装系统 Python(慢/版本旧)
yum install python3 在老版本 CentOS(如 7)上只能装到 Python 3.6编译安装(最慢但最灵活)
./configure && make && make installgcc、make、openssl-devel 等),还会报错重来网络问题
dnf(CentOS 8+)dnf install python3 -y
速度正常,版本较新(3.8+)
curl https://pyenv.run | bash
pyenv install 3.11.6
bash Miniconda3-latest-Linux-x86_64.sh
# pip 换国内源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# CentOS 7 编译依赖
yum install -y gcc make zlib-devel bzip2-devel \
openssl-devel ncurses-devel sqlite-devel readline-devel
如果你说的是 CentOS 几 + 装哪种 Python + 用途(Web / 爬虫 / AI),我可以给你最合适的一条命令。