Anaconda基本环境创建、安装、删除、搭建命令、Anaconda及pip更换源教程

Anaconda基本环境创建、安装、删除、搭建命令、Anaconda及pip更换源教程

1.列出所有环境

conda env list

2.创建一个环境

#python=3.8:指定python版本
conda create --name tfpy3.8(环境名) python=3.8

3.进入环境

conda activate env_demo(环境名)

进入环境后就可以查询该环境下的python版本等

python

4.退出环境,进入基础环境

conda deactivate

5.删除某个环境

#--all:删除改环境下所有的包
conda remove --name env_demo(环境名) --all

6.查看环境安装的包

conda list

7.删除环境钟的某个包

conda remove --name $your_env_name  $package_name 

Anaconda更换源

更换condan源

参见:anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

1.生成.condarc文件

各系统都可以通过修改用户目录下的 .condarc 文件。若Windows 用户没有名为 .condarc 的文件,可先执行:

conda config --set show_channel_urls yes

2.生成该文件之后再修改

conda config --set show_channel_urls yes

3.修改 .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
  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

4.清除索引缓存

运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引

conda clean -i

5.查看源

conda config --show-sources

更换pip源

永久使用:

第一步: 在C:\Users\Administrator 目录下 创建pip文件夹 第二步:在第一步创建的文件夹下(C:\Users\Administrator\pip)创建pip.ini文件 第三步:记事本编辑保存pip.ini文件内容为以下部分:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

猜你喜欢

转载自blog.csdn.net/weixin_43227851/article/details/133467788
今日推荐