Files
docs/开发文档/python/Anaconda用法.md
2026-01-14 11:27:47 +08:00

69 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 'Anaconda用法'
date: '2022/03/28 20:00'
tags: [python, 虚拟化, anaconda, 文档教程]
categories:
- 软件用法
---
# Anaconda用法
- Anaconda下载地址https://www.anaconda.com/download/
- Miniconda下载地址https://docs.conda.io/en/latest/miniconda.html
- 清华大学的conda源https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
- 配置清华大学conda源
```ini
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
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
```
## linux下载链接
```sh
wget https://repo.anaconda.com/miniconda/Miniconda3-py311_24.1.2-0-Linux-x86_64.sh
sudo bash Miniconda3-py311_24.1.2-0-Linux-x86_64.sh
```
### conda命令用法
- 删除虚拟环境
`conda env remove --name myenv`
- 删除指定路径的虚拟环境
`conda env remove -p /完整/路径/到/环境`
- 查看虚拟环境
`conda env list或conda info --envs`
- windows下在用户目录下创建conda配置文件,文件名.condarc,linux下会自动创建无需手动创建
`conda config --set show_channel_urls yes`
- 清除索引缓存
`conda clean -i`
> 更改conda源后使用
- 创建一个名为envname的虚拟环境,并安装python=3.6
`conda create --name envname python=3.6`
> 默认在用户目录下创建
- 指定目录创建环境,在d盘virtual目录下创建名为tensorflow的虚拟环境
`conda create --prefix=d:\virtual\tensorflow`
> 使用prefix时,不能指定虚拟环境名称,给定的路径最后一个目录即为虚拟环境名称
- 取消自动激活conda环境
`conda config --set auto_activate_base false`
- 在conda环境中安装包虚拟环境名称可以不用指定
`conda install --name envname package1 package2`
- 在conda环境中卸载包remove和uninstall效果一样
`conda remove --name envname package1 package2`
- 查询conda包可以不输入完整的包名
`conda search packagename`
- 查询指定conda包的可用版本
`conda search packagename==`
- 列出conda包
`conda list`
- 更新conda包
`conda update --name envname package1 package2`