栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ubuntu Anaconda的安装、镜像源更改和python虚拟环境的配置细节

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu Anaconda的安装、镜像源更改和python虚拟环境的配置细节

一:Anaconda的安装 步骤一:在清华镜像anaconda地址下载Linux版本的anaconda 步骤二:2.在用户文件夹下新建一个名为anaconda的文件夹,并将刚刚下载的文件放在此文件夹中 步骤三:右键点击文件夹,点击在终端中打开,运行如下代码解压下载:
bash Anaconda3-2021.11-Linux-x86_64.sh
步骤四:安装好conda后,先关闭终端,然后看到前面有了一个(base)其实就是成功了,可以再进行验证,输入如下代码查看anaconda版本号:
$ conda --version

若还是显示找不到conda指令,可看这篇博文

步骤五:进行初始化
$ conda init
二:conda镜像源更改

参考的这篇博文,直接上代码!

conda config --show channels #查看目前已有的镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/#添加清华源
conda config --set show_channel_urls yes#从channel中安装包时显示channel的url,这样就可以知道包的安装来源
conda config --show channels#验证一下配置是否成功

建议添加的镜像源:

国内常用的anaconda镜像:
http://mirrors.aliyun.com/pypi/simple/ #阿里
https://pypi.tuna.tsinghua.edu.cn/simple/ #清华
http://pypi.douban.com/ #豆瓣
http://pypi.mirrors.ustc.edu.cn/ #中国科学技术大学

建议下面也全部添加,虽然有些可能用不到,但是实际包含比较冷门的包
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --set show_channel_urls yes

笔者在后几次装环境配置,发现会报错源找不到,可使用以下方法

conda config --remove-key channels #恢复默认源

#添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ 

#添加中科大源头
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
三:python虚拟环境的配置细节

话不多说,直接上代码!

conda activate
conda create -n [env_name] python=3.8
conda activate [env_name]

至此,python虚拟环境成功建成。若要安装依赖,直接进虚拟环境后,使用conda install或pip install都行,会自动添加到python中。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/980205.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号