Anaconda
修改源
不同系统下的 .condarc 目录如下:
- Linux:
${HOME}/.condarc - macOS:
${HOME}/.condarc - Windows:
C:\Users\<YourUserName>\.condarc
- Windows 用户无法直接创建名为
.condarc的文件,可先执行conda config --set show_channel_urls yes生成该文件之后再修改。- 添加环境变量:
D:\ProgramData\anaconda3\Scripts- 修改内网源时,除了修改
C:\Users\<YourUserName>\.condarc,还需要安装目录下的.condarc
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
常用命令
$ conda
usage: conda-script.py [-h] [-v] [--no-plugins] [-V] COMMAND ...
conda is a tool for managing and deploying applications, environments and packages.
optional arguments:
-h, --help Show this help message and exit.
-v, --verbose Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG
logging, four times for TRACE logging.
--no-plugins Disable all plugins that are not built into conda.
-V, --version Show the conda version number and exit.
commands:
The following built-in and plugins subcommands are available.
COMMAND
activate Activate a conda environment.
clean Remove unused packages and caches.
commands List all available conda subcommands (including those from plugins). Generally only used by tab-
completion.
compare Compare packages between conda environments.
config Modify configuration values in .condarc.
content-trust Signing and verification tools for Conda
create Create a new conda environment from a list of specified packages.
deactivate Deactivate the current active conda environment.
doctor Display a health report for your environment.
export Export a given environment
info Display information about current conda install.
init Initialize conda for shell interaction.
install Install a list of packages into a specified conda environment.
list List installed packages in a conda environment.
notices Retrieve latest channel notifications.
package Create low-level conda packages. (EXPERIMENTAL)
remove (uninstall)
Remove a list of packages from a specified conda environment.
rename Rename an existing environment.
repoquery Advanced search for repodata.
run Run an executable in a conda environment.
search Search for packages and display associated information using the MatchSpec format.
update (upgrade) Update conda packages to the latest compatible version.
创建一个新的虚拟环境
conda create -n env_name python=3.10
conda init bash
查看所有环境的列表
conda info --envs
conda env list
激活新创建的虚拟环境:
conda activate myenv
禁用在使用中的虚拟环境:
conda deactivate
查看 Conda 的配置
conda config --show
# 不自动激活base环境
conda config --set auto_activate_base false
conda info # 查看信息
conda list # 查看安装的包
conda remove -n env_name --all # 删除环境
conda install package_name # 安装包
conda remove package_name # 删除包
conda clean -i # 清除索引缓存