当前位置:首页 > 生活小常识 > 正文
已解决

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

来自网友在路上 149849提问 提问时间:2023-07-31 22:05:54阅读次数: 49

最佳答案 问答题库498位专家为你答疑解惑

关于【查看conda源】,如何用conda查看镜像源,今天犇涌小编给您分享一下,如果对您有所帮助别忘了关注本站哦。

内容导航:1、查看conda源:Anaconda详细教程2、查看conda源,如何用conda查看镜像源

1、查看conda源:Anaconda详细教程

Anaconda介绍、安装及使用教程

前言

Python是一种面向对象的解释型计算机程序设计语言,具有跨平台的特点,可以在Linux、macOS以及Windows系统中搭建环境并使用,其编写的代码在不同平台上运行时,几乎不需要做较大的改动就能运行。

Python的应用遍及人工智能、科学计算、Web开发、系统运维、大数据及云计算、金融、游戏开发等,具有数量庞大且功能相对完善的标准库和第三方库。

一、Anaconda

1、简介

Anaconda是大型的科学计算平台,是Python集成开发环境,包含了大量的科学包,能够方便快捷的对程序包进行管理和部署。

2、特点

安装简单包含了数百个科学模块,高效运用于各种项目免费社区支持Anaconda 是跨平台的,有 Windows、macOS、Linux 版本支持多种语言:Python、R、Java等

3、包管理工具——conda

3.1 升级

升级Anaconda需要先升级conda

condaupdatecondacondaupdateanacondacondaupdateanaconda-navigator#最新版本的anaconda-navigator

3.2 卸载

Linux、Mac 删除安装路径

rm-rfanaconda

3.3 基本命令

conda--version#查看conda版本condaupdate-nbaseconda#update最新版本的condacondacreate-nxxxx#创建名为xxxx的虚拟环境condacreate-nxxxxpython=3.5#创建包含python3.5的名为xxxx的虚拟环境condaremove-nxxxx--all#删除名为xxxx的虚拟环境condaactivatexxxx#进入xxxx环境sourceactivatexxxxcondadeactivate#退出环境sourceactivatecondaenvlist#显示所有的虚拟环境condainfo--envs#查看当前环境condaclean-p#删除没有用的包condaclean-t#tar打包condaclean-y-all#删除所有的安装包及cache

3.4 对包的操作

condalist#查看所有已经安装的包condalist-nxxxx#指定查看xxxx虚拟环境下安装的packagecondainstall-nxxxxxxx#在指定环境中安装xxx包condaupdatexxx#更新包xxxcondauninstallxxx#卸载包xxx

3.5 镜像源

condaconfig--show#查看已经安装过的镜像源condaconfig--removechannelsurl#删除url源condaconfig--addchannels#添加url源condaconfig--setshow_channel_urlsyes#从channel中安装包时显示channel的url

修改配置文件 ~/.condarc

channels:-https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/-https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/-https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/-defaultsshow_channel_urls:true

查看是否生效

condainfo

4、pip

4.1 基本命令

pip--version#查看版本pip--help#获取帮助pipinstall-Upip#升级pippipinstallpkg#安装包pipinstallpkg=version#安装指定版本的包pipinstall--upgradepkg#升级包pipuninstallpkg#卸载包pipsearchpkg#搜索包pipshow#显示安装包信息pipshow-fpkg#查看指定包的详细信息piplist#列出已安装的包piplist-o#查看可升级的包

4、2 升级

Linux、Mac

pipinstall--upgradepip

windows

python-mpipinstall-Upip

4、3 镜像源

临时使用清华源

pipinstall-ihttps://pypi.tuna.tsinghua.edu.cn/simplesome-package

永久修改

Linux、Mac:~/.pip/pip.conf

windows:C:\Users\xx\pip\pip.ini

[global]index-url = https://pypi.tuna.tsinghua.edu.cn/simple# 阿里云 http://mirrors.aliyun.com/pypi/simple/ # 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ # 豆瓣(douban) http://pypi.douban.com/simple/ # 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ # 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/[install]trusted-host = mirrors.aliyun.com

二、安装

官网地址:https://www.anaconda.com/

1、Windows

安装时一般默认就行,在Advanced Installation Options这一步,不要勾选Add Anaconda to my PATH environment variable

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

2、Linux

命令行安装

bash~/Downloads/Anaconda3-5.0.1-MacOSX-x86_64.sh安装过程中,出现提示Press Enter to confirm the location, Press CTRL-C to cancel the installation or specify an alternate installation directory.如果接受默认安装路径,则会显示 PREFIX=/home/<user>/anaconda<2 or 3> 并且继续安装。出现提示Do you wish the installer to prepend the Anaconda install location to PATH in your /home/<user>/.bash_profile ?建议输入yes。

3、Mac

前面直接下一步

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

在这,可以点击Change Install Location来改变安装位置。

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

完成!

点击Anaconda-Navigator的图标,打开

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

启动成功,说明安装完成。

三、jupyter

1、notebook环境配置

1.1、Windows

打开控制面板->系统->高级系统设置->环境变量,选中系统变量中的path进行添加

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

在Anaconda安装位置下的的Script目录及Library\bin目录复制进去,如

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

2、配置

2.1、生成配置文件

jupyternotebook--generate-config

2.2、设置密码

jupyternotebookpassword#这步设置的密码用于浏览器访问时输入

2.3、修改配置文件

Windows

C:\Users\Administrator\.jupyter\jupyter_notebook_config.py

Linux、Mac

vim~/.jupyter/jupyter_notebook_config.py

#前面的#去掉c.NotebookApp.ip='*'#开启所有的IP访问,即可使用远程访问c.NotebookApp.open_browser=False#关闭启动后的自动开启浏览器c.NotebookApp.port=8888#设置端口8888,也可用其他的,比如1080,8080等等c.NotebookApp.notebook_dir=’‘#设置notebook默认打开的目录c.PAMAuthenticator.encoding='utf8'#指定utf-8编码,解决读取中文路径或者文件乱码问题

2.4、启动notebook

jupyternotebook#启动notebookjupyterlab#启动lab

2.5 远程登录

启动notebook之后在浏览器中输入启动是打印的网址或者:

localhost:port/tree#进入jupyternotebooklocalhost:port/lab#进入jupyterlab

jupyter在服务器服务器,想在本地浏览器访问时,需要在终端输入命令

ssh-N-Llocalhost:7777:login-0-0.local:12315dengxsh4490@10.100.2.10

注:localhost:7777指定本地浏览器需要输入的地址,login-0-0.local:12315代表服务器运行jupyter时打印的输出信息中的地址

3、jupyter kernel

3.1 扩展 R kernel

install.package('IRkernel')#displayname指定jupyter中显示的名字IRkernel::installspec(name='ir32',displayname='R3.2')

3.2 查看kernel

jupyterkernelspeclist

3.3 卸载指定kernel

jupyterkernelspecremovekernel_name

四、jupyter 插件

1、jupyter notebook 插件

1.1、安装并激活 jupyter_contrib_nbextensions

pipinstalljupyter_contrib_nbextensionsjupytercontribnbextensioninstall--user

1.2、 安装并启用 Jupyter Nbextensions Configurator

pipinstalljupyter_nbextensions_configuratorjupyternbextensions_configuratorenable--user

1.3、conda安装的方式

condainstall-cconda-forgejupyter_contrib_nbextensionscondainstall-cconda-forgejupyter_nbextensions_configurator

可替代1.1和1.2

完成后,在启动 jupyter notebook后可在浏览器菜单栏中多了一栏

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

选中想要的插件即可添加

1.4、插件选择

Variable Inspector:这是一个查看变量的插件

Table of Contents:自动生成目录插件

Table of Contents:自动生成目录插件

Codefolding:代码折叠

Autopep8:自动代码格式优化

AutoSaveTime:控制脚本的自动保存时间

Hide Input All: 隐藏所有的代码单元,保持所有的输出和 markdown 单元可见

Spellchecker: 对 markdown 单元中的内容进行拼写检查

插件很多,可根据需要添加

2、jupyter lab插件

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

点击菜单栏Settings下拉框中的Advanced Settings Editor选项,进入设置页面

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

接着,点击Extension Manager,并且在右边的空白框里填上{'enabled':true},并且按右上角的保存按钮。

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

最后,你会看到Lab右边会出现插件栏的按钮,我已经安装过一些插件

介绍几款好用的插件

注:安装这些插件需要先安装 node,并将node添加到环境变量中。安装时请注意node版本

2.1、toc

这是一个目录插件,安装后就能很方便地在Lab上展示notebook或者markdown的目录。目录可以滚动,并且能展示或隐藏子目录。

https://link.zhihu.com/?target=https%3A//github.com/jupyterlab/jupyterlab-toc

2.2、LaTeX

支持在线编辑并预览LaTeX文档。

https://link.zhihu.com/?target=https%3A//github.com/jupyterlab/jupyterlab-latex

2.3、drawio

可以在Lab中启用drawio绘图工具,是一款非常棒的流程图工具。

https://link.zhihu.com/?target=https%3A//github.com/QuantStack/jupyterlab-drawio

2.4、variableinspector

该插件可以在Lab中展示代码中的变量及其属性,类似RStudio中的变量检查器。

https://link.zhihu.com/?target=https%3A//github.com/lckr/jupyterlab-variableInspector

2.5、go to Definition

该插件用于在Lab笔记本和文件编辑器中跳转到变量或函数的定义。

https://link.zhihu.com/?target=https%3A//github.com/krassowski/jupyterlab-go-to-definition

2.6、lsp

该插件用于自动补全、参数建议、函数文档查询、跳转定义等。

https://link.zhihu.com/?target=https%3A//github.com/krassowski/jupyterlab-lsp

2.7 spreadsheet

该插件用于在Lab上显示excel表格,只读

https://link.zhihu.com/?target=https%3A//github.com/quigleyj97/jupyterlab-spreadsheet

2.8、debugger

可用于试调

condainstallxeus-python=0.8.0-cconda-forgejupyterlabextensioninstall@jupyterlab/debugger

https://github.com/jupyterlab/debugger

2.9、matplotlib、dash、plotly等可交互式绘图

帮助我们在notebook界面配合matplotlib实现交互式的作图,只需要在绘图之前执行魔法命令%matplotlib widget

matplotlib:https://github.com/matplotlib/ipympl

plotly:https://github.com/plotly/plotly.py

2.10、kite

在jupyter lab使用kite代码补全服务

https://github.com/kiteco/jupyterlab-kite

2、查看conda源,如何用conda查看镜像源

软件安装是生信分析的基础,除了掌握基本的软件安装理论外之后 (Linux - 命令运行监测和软件安装),就是去下载源码安装或使用包管理工具安装通常操作都没问题时,软件却怎么都装不上,这一般都是网络问题所以你需要一个能够快速访问的镜像,下载快还不容易断,今天小编就来说说关于如何用conda查看镜像源?下面更多详细答案一起来看看吧!

查看conda源,如何用conda查看镜像源(Anaconda详细教程)

如何用conda查看镜像源

软件安装是生信分析的基础,除了掌握基本的软件安装理论外之后 (Linux - 命令运行监测和软件安装),就是去下载源码安装或使用包管理工具安装。通常操作都没问题时,软件却怎么都装不上,这一般都是网络问题。所以你需要一个能够快速访问的镜像,下载快还不容易断。

国内的镜像比较全的有清华镜像 (https://mirrors.tuna.tsinghua.edu.cn)和阿里云镜像 (https://developer.aliyun.com/mirror/)。下面以清华镜像为例 (阿里云镜像没有conda),展示下其操作。

Conda镜像

Conda增加清华的镜像,运行下面的代码 (后添加的通道优先级更高)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mainconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freeconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/rconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/proconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2conda 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/bioconda/

或直接把下面文字拷贝到 ~/.condarc中 (越靠前的优先级越高)

channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

Python包管理工具 pip镜像

可以每次安装时加-i参数 (或使用alias命令)。

注意,simple不能少, 是https而不是 http。

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

升级 pip 到最新的版本 (>=10.0.0) 后进行永久配置:

pip install pip -Upip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

R包安装镜像

CRAN和Bioconductor的镜像

安装前现运行这几句话,或把这几句话放在~/.Rprofile或~/.Profile.site文件下 (Windows里面的路径是C:\Program Files\R\R-3.6.1\etc)。

local({r <- getOption("repos")r["CRAN"] <- "http://mirrors.tuna.tsinghua.edu.cn/CRAN/"options(repos=r)})options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")

自动安装包

# 安装BiocManagerif (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager")# 获取已安装包a = rownames(installed.packages())install_package <- c("RColorBrewer", "gplots", "agricolae","optparse")# 判断包是否存在,不存在则安装for (i in install_package) { if (!i %in% a) BiocManager::install(i, update = F)}

如果是Github的包安装起来比较慢,可以考虑在码云(https://gitee.com/)注册个账户,把`Github`的库先克隆到码云 (点击几下就可以实现,码云的服务器访问Github还是很快的),然后再下载到本地安装即可。

HomeBrew

Mac下默认的不少Linux命令如awk, sed,cat等与Linux下使用方式有些差别,通常需要安装GNU系列的对应命令来统一代码操作。可以通过brew安装,但brew update过程默认是极其的慢,也需要改一下镜像。

安装Brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

配置镜像

# brew 程序本身,Homebrew/Linuxbrew 相同git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git# 索引的镜像# 以下针对 mac OS 系统上的 Homebrewgit -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.gitgit -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.gitgit -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.gitgit -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git# 更换后测试工作是否正常brew update# 软件包的镜像echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profilesource ~/.bash_profile

安装相应的gnu系列工具

#brew install bashbrew install coreutilsbrew install gawkbrew install gnu-sed

其它镜像

还有其它镜像,如Perl的CPAN,Linux操作系统安装包,Linux操作系统自带包管理工具(yum/apt)的源,Docker镜像等。

本文关键词:设置conda源,查看conda路径,conda版本怎么看,conda配置源,查看conda的环境。这就是关于《查看conda源,如何用conda查看镜像源(Anaconda详细教程)》的所有内容,希望对您能有所帮助!更多的知识请继续关注《犇涌向乾》百科知识网站:!

99%的人还看了

猜你感兴趣

版权申明

本文" 查看conda源,如何用conda查看镜像源(Anaconda详细教程)":http://eshow365.cn/3-2779-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!