Python常用命令

作者:追风剑情 发布于:2026-4-9 15:22 分类:Python

一、配置镜像地址

# 配置清华镜像源(国内最快最稳定)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
# 验证配置是否成功
conda config --show channels  

二、初始化命令窗口

# 为 cmd.exe 初始化 conda,需要以管理员身份重新打开cmd窗口
conda init cmd.exe
# 为 PowerShell 初始化 conda,需要以管理员身份重新打开PowerShell窗口
conda init powershell
 

三、创建虚拟环境

# 创建一个 Python 3.12 的环境
conda create -n pyocc-env python=3.12
# 激活虚拟环境
conda activate pyocc-env
# 删除环境
conda env remove -n pyocc-env
# 查看当前环境列表
conda env list
# 查看当前激活的环境,前面有*
conda info --envs 
# 退出当前环境
conda deactivate
 

四、安装 pythonOCC

# 创建一个 Python 3.12 的环境并安装 pythonOCC
conda create -n pyocc-env python=3.12
# 为 cmd.exe 初始化 conda,需要以管理员身份重新打开cmd窗口
conda init cmd.exe
# 为 PowerShell 初始化 conda,需要以管理员身份重新打开PowerShell窗口
conda init powershell
# 激活虚拟环境
conda activate pyocc-env
# 删除环境
conda env remove -n pyocc-env
# 安装 pythonocc
conda install -c conda-forge pythonocc-core=7.9.0 

# 查看 conda 版本
conda --version
# 查看当前环境列表
conda env list
# 查看当前激活的环境,前面有*
conda info --envs 
# 退出当前环境
conda deactivate
# 清理 conda 缓存
conda clean --all -y  

标签: Python

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号