conda快速开始
conda部分
安装 miniconda 后设置环境变量
# python
C:\ProgramData\miniconda3
# pip, conda ...
C:\ProgramData\miniconda3\Scripts
快速打开终端
win + R > wt > ctrl + shift + enter
初始化
conda init -h
conda init powershell
conda init cmd.exe
如果初始化后出现
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# 如果提示是否确认更改,输入Y即可
修改源
# 生成 .condarc 配置文件
conda config --set show_channel_urls yes
# 添加镜像源
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/
# 更新 .condarc 配置文件
conda config --set show_channel_urls yes
# 清理缓存
conda clean -i
# 验证修改是否成功
conda config --show channels
# 恢复默认源
conda config --remove-key channels
# 也可以修改.condarc文件来更改
创建环境
查看环境
conda env list
创建虚拟环境
conda create -n <名称> python=3.13
# -n name
激活环境
conda activate <名称>
python -V
pip -V
删除环境
conda env remove -n <名称>
清理 conda 缓存
conda clean --all
安装命令
conda install
pip换源
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
#阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
#腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
#豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
## 恢复默认源
pip config unset global.index-url
基础指令
pip
pip install xxx
# 指定版本
pip install xxx==0.0.1
# 批量安装
pip install requests numpy pandas
# 升级包
pip install --upgrade numpy
# 卸载包
pip uninstall numpy
pip list
conda
conda install numpy
# 指定频道(如 conda-forge)
# -c:是 --channel 的缩写,用于指定安装来源渠道
# conda-forge:该源比官方默认渠道更新更快、更安全
conda install -c conda-forge langchain==0.3.7
# 更新包
conda update langchain
# 卸载包
conda uninstall langchain
# 查看已安装包
conda list
# 通过文件安装
conda install --file requirements.txt
