When using anaconda to create a virtual environment, a large number of common libraries and python version problems encountered are automatically installed, and Tsinghua source configuration is performed

question

When creating a new virtual environment in anaconda, it always installs several default libraries, and will not install all commonly used libraries like the base environment. The following situation occurs.
insert image description here

Solution

When creating an environment, use the command conda create -n (environment name) python= (version number) anaconda

You can create an environment and automatically install common libraries.

#创建环境时使用加后缀  anaconda
conda create -n test python=3.6.0 anaconda
# test 为环境名

insert image description here

Special case

It's not clear yet, I haven't dug into the reason. Due to the installation of some deep learning frameworks, a python3.6.2 environment is required.
After installing the python3.6.2 version, common libraries cannot be installed automatically even if the suffix anaconda is added. Tried to download 3.7 (haven't tried 3.8 yet)

#创建环境时使用加后缀  anaconda
conda create -n test python=3.6.2 anaconda
.....
或 conda create -n test python=3.6.10 anaconda

insert image description here

Temporarily resolve this situation by first installing the python3.6.1 environment and then installing python3.6.2.

#创建环境时使用加后缀  anaconda
conda create -n test python=3.6.1
conda activate test
# 记得输入-n 虚拟环境名
conda install python==3.7 -n test

Download the python3.7 environment. It is speculated that the configuration of the anaconda source (preliminary judgment) and the updated version of the configured Tsinghua source can solve this problem. Revisit Tsinghuayuan website https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

#生成.condarc 文件 
conda config --set show_channel_urls yes
# 若之前已存在其他源,则输入还原anaconda默认源,没有则不用以下命名
# conda config --remove-key channels
# 编辑配置文件
vim .condarc
# 清除索引缓存,保证用的是镜像站提供的索引。
conda clean -i 

# 进入之后,将原有配置命名注释,复制粘贴新配置命令,打开上方的清华源网站,复制粘贴内容,保存。如下图:

insert image description here

# 查看配置信息,完成配置
conda info
# 之后安装python3.7 ,环境名:test,即可完成环境配置
conda create -n test python=3.7 anaconda

insert image description here
insert image description here
you're done

Guess you like

Origin blog.csdn.net/Fuziqp/article/details/125934684