Anaconda
信息
Anaconda 提供了在一台机器上执行 Python/R 数据科学和机器学习的最简单方法。
| 官网 | Anaconda 文档 | conda 文档 |
安装
- 前往官网 下载安装
- 使用 Chocolatey 安装
choco install anaconda3 -y
安装完成后开始菜单中会有以下程序:
配置
在 PowerShell 中启用 conda
以 管理员身份运行 Anaconda Powershell Prompt 并执行以下指令:
conda init powershell
启动 PowerShell 时不要默认启动 Anaconda:
conda config --set auto_activate_base False
需要时可手动启动:
conda activate base
配置镜像源
- anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
- anaconda镜像_anaconda下载地址_anaconda安装教程-阿里巴巴开源镜像站
修改用户目录下的 .condarc
文件,没有该文件可以使用 conda config --set show_channel_urls yes
生成。
~/.condarc
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.aliyun.com/anaconda/pkgs/main
- http://mirrors.aliyun.com/anaconda/pkgs/r
- http://mirrors.aliyun.com/anaconda/pkgs/msys2
# - 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: http://mirrors.aliyun.com/anaconda/cloud
msys2: http://mirrors.aliyun.com/anaconda/cloud
bioconda: http://mirrors.aliyun.com/anaconda/cloud
menpo: http://mirrors.aliyun.com/anaconda/cloud
pytorch: http://mirrors.aliyun.com/anaconda/cloud
simpleitk: http://mirrors.aliyun.com/anaconda/cloud
# conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
PyChram
选择 Conda 可执行文件路径
选择 Anaconda 安装目录中的:Anaconda3\Scripts\conda.exe
文件即可。
终端无法激活 conda 环境
建议使用 Powershell 7;
安装后 Shell 路径设置为:C:\Program Files\PowerShell\7\pwsh.exe
使用
安装完成后可使用 conda
命令:
conda -h
(base) PS C:\Users\Yue_plus> conda -h
usage: conda-script.py [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
Options:
positional arguments:
command
clean Remove unused packages and caches.
compare Compare packages between conda environments.
config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (C:\Users\Yue_plus\.condarc) by default. Use the --show-sources flag
to display all identified configuration locations on your computer.
create Create a new conda environment from a list of specified packages.
info Display information about current conda install.
init Initialize conda for shell interaction.
install Installs a list of packages into a specified conda environment.
list List installed packages in a conda environment.
package Low-level conda package utility. (EXPERIMENTAL)
remove Remove a list of packages from a specified conda environment.
rename Renames an existing environment.
run Run an executable in a conda environment.
search Search for packages and display associated information.The input is a MatchSpec, a query language for conda packages. See examples below.
uninstall Alias for conda remove.
update Updates conda packages to the latest compatible version.
upgrade Alias for conda update.
notices Retrieves latest channel notifications.
optional arguments:
-h, --help Show this help message and exit.
-V, --version Show the conda version number and exit.
conda commands available from other packages:
build
content-trust
convert
debug
develop
env
index
inspect
metapackage
pack
render
repo
server
skeleton
token
verify
依赖包管理文件
conda 通常使用 environment.yml
文件记录依赖包。
导出当前环境的依赖
conda env export --from-history > environment.yaml
从文件创建新环境
conda env create --file environment.yml