env
miniconda
-
下载安装脚本
Bash 1wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -
执行安装脚本
默认安装在
~/miniconda3目录下Bash 1bash Miniconda3-latest-Linux-x86_64.sh -bBash 1rm 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 1echo 'export PATH=$HOME/miniconda3/bin:$PATH' >> ~/.bashrcBash 1source ~/.bashrc -
验证
Bash 1 2
conda init source ~/.bashrc -
删除默认启动
base环境Bash 1conda config --set auto_activate_base false
for windows
| Bash | |
|---|---|
1 2 3 4 | |
command
-
查看所有环境
Bash 1conda 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 1conda activate py27 -
退出环境
Bash 1conda deactivate -
删除环境
Bash 1conda remove -n py27 --all -
查看环境中已安装的软件
Bash 1conda list -
安装软件
Bash 1conda install django -
卸载软件
Bash 1conda 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 1wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz -
下载依赖包
Bash 1apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev -
解压源码包
Bash 1tar -xvf Python-3.12.0.tar.xz -
运行配置脚本
Bash 1 2
cd Python-3.12.0 ./configure --enable-optimizations -
编译
Bash 1make -j8 # 多线程编译 -
安装
Bash 1make altinstall -
验证
Bash 1python3.12 -V