在 Ubuntu 上装 Python,常见有几种方式,看你需求:
Ubuntu 一般默认已经装了 Python 3
python3 --version
如果没有,直接装:
sudo apt update
sudo apt install python3 python3-pip
比如装 Python 3.11:
sudo apt install python3.11
适合开发,不影响系统 Python:
sudo apt install curl git build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
curl https://pyenv.run | bash
然后:
pyenv install 3.12.1
pyenv global 3.12.1
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
wget https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz
tar xzf Python-3.12.1.tgz
cd Python-3.12.1
./configure --enable-optimizations
make -j$(nproc)
sudo make altinstall
apt 就行pyenvconda你是要干啥用的?我可以给你更具体的命令。