Conda

常用命令

换源

conda config --add channels [url]
清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
conda config --set show_channel_urls yes

创建环境

conda create -n [EnvName] python=[Version]
Example
conda create -n TEST python=3.8

切换环境

conda activate [EnvName]

退出环境

conda deactivate

环境列表

conda env list

删除环境

conda env remove -n [EnvName]

基础环境配置

Jupyter环境

conda install jupyter

Data Analysis

# 创建数据分析环境
conda create -n data_analysis python=3.9
# 激活环境
conda activate data_analysis
# 安装常用的数据分析库
conda install numpy pandas matplotlib seaborn scikit-learn jupyter
# 安装其他有用的数据分析工具
conda install -c conda-forge jupyterlab ipython statsmodels

Deep Learning

# 创建深度学习环境
conda create -n deep_learning python=3.9

# 激活环境
conda activate deep_learning

# 安装 TensorFlow
conda install tensorflow

# 安装 PyTorch
conda install pytorch torchvision torchaudio cpuonly -c pytorch

# 安装其他常用的深度学习库
conda install -c conda-forge keras matplotlib pandas scikit-learn jupyter

CV

# 创建计算机视觉环境
conda create -n computer_vision python=3.9
# 激活环境
conda activate computer_vision
# 安装 OpenCV
conda install -c conda-forge opencv
# 安装其他常用的计算机视觉库
conda install numpy matplotlib scikit-learn jupyter
# 安装深度学习库(用于计算机视觉任务)
conda install tensorflow pytorch torchvision torchaudio cpuonly -c pytorch
# 安装图像处理库
conda install scikit-image pillow

NLP

# 创建 NLP 环境
conda create -n nlp python=3.9

# 激活环境
conda activate nlp

# 安装常用的 NLP 库
conda install -c conda-forge spacy nltk gensim

# 安装深度学习库
conda install snownlp tensorflow pytorch torchvision torchaudio cpuonly -c pytorch

# 安装其他有用的库
conda install pandas scikit-learn matplotlib

# 安装 transformers 库(用于预训练模型)
pip install transformers

# 安装 jupyter 和 jupyterlab
conda install -c conda-forge jupyter jupyterlab

# 下载和安装 spaCy 语言模型(例如 en_core_web_sm)
python -m spacy download en_core_web_sm