env
miniconda
-
下载安装脚本
Bash 1
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
-
执行安装脚本
默认安装在
~/miniconda3
目录下Bash 1
bash Miniconda3-latest-Linux-x86_64.sh -b
Bash 1
rm Miniconda3-latest-Linux-x86_64.sh
-
更新
Bash 1 2 3 4
~/miniconda3/bin/conda update -n base -c defaults conda # -n 指定环境为 base # -c 指定源为 defaults # conda 软件名
-
配置环境变量
Bash 1
echo 'export PATH=$HOME/miniconda3/bin:$PATH' >> ~/.bashrc
Bash 1
source ~/.bashrc
-
验证
Bash 1 2
conda init source ~/.bashrc
-
删除默认启动
base
环境Bash 1
conda config --set auto_activate_base false
command
-
查看所有环境
Bash 1
conda info -e
-
创建环境
Bash 1 2 3 4
conda create -n py27 python=2.7 # 创建名为 py27 的环境,使用 Python 2.7 conda create -n py36 python=3.6 django=1.11 # 创建名为 py36 的环境,使用 Python 3.6,安装 Django 1.11
-
激活环境
Bash 1
conda activate py27
-
退出环境
Bash 1
conda deactivate
-
删除环境
Bash 1
conda remove -n py27 --all
-
查看环境中已安装的软件
Bash 1
conda list
-
安装软件
Bash 1
conda install django
-
卸载软件
Bash 1
conda remove django
pip
- 下载
wget https://bootstrap.pypa.io/get-pip.py
- 安装
python get-pip.py
- 测试
python -m pip --version
查看当前软件包
pip list
通过源码构建特定版本的 Python
以下是在 Ubuntu 20.04
上构建 Python 3.12.0
的步骤。
-
下载源码包
Bash 1
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz
-
下载依赖包
Bash 1
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
-
解压源码包
Bash 1
tar -xvf Python-3.12.0.tar.xz
-
运行配置脚本
Bash 1 2
cd Python-3.12.0 ./configure --enable-optimizations
-
编译
Bash 1
make -j8 # 多线程编译
-
安装
Bash 1
make altinstall
-
验证
Bash 1
python3.12 -V