众所周知,小洁老师乃是一只资深的R语言讲师,为了后面更丰富的单细胞分析需求(是的,可以期待出课程,一帮学员催我现学然后教他们),准备把python搞起! python的IDE很丰富,可能别人会推荐使用jupyter lab,jupyter notebook,vscode,sublime等,但是在众多的IDE中我注意到一句话:Spyder是目前最接近Rstudio的IDE,所以我就选了它! 其实还有一个Positron,是Rstudio的公司出品的,可以无缝切换Python和R,目前还不是特别完善,但它可能是未来的主流!
就先看看设置之后的Spyder软件界面,没有一个R语言使用者可以拒绝:
整个一个R里R气!我很喜欢。 下面分享一下要怎么搞它,虽然在各位读者眼里我是个带路的,但是这对我来说也是新知识,一家之言,不保证是最正确最好的,如果后面有改变,那我会在评论区补充。也欢迎各位资深python用户来分享自己的看法。
装miniconda会自带python,它可以用于安装其他软件,是个应用商店。 下载地址: 清华大学开源软件镜像站 https://mirrors.tuna.tsinghua.edu.cn/
右侧<获取下载链接>-应用软件-conda-最前面的,按照自己的系统选择win和mac对应的版本。win要exe,mac要pkg即可,装起来比较简单。(sh是脚本,不要它)
下载下来后和普通软件一样的安装方式,就一路点点点。装好之后和其他软件一样可以在开始菜单里找到
后面的命令行代码都是在这个anaconda prompt窗口里运行的。
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
conda config --set show_channel_urls yes
然后找到.condarc文件(可以用everything软件搜索),把官网上面的内容(如下)复制粘贴进去
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
deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
从官方文档上面查找发现支持用conda安装,如果使用默认的安装包来安装,那么我们要用到的重要插件notebook就不能用。
conda create -c conda-forge -n spyder-env spyder numpy scipy pandas matplotlib sympy cython
conda activate spyder-env
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
两种方式,一种是从开始菜单找(spyder-env)
一种是命令行启动(在anaconda promt窗口运行) 需要先用conda activate激活环境(一些尘封的linux知识点,不会也影响用),然后运行spyder就打开了界面
conda activate spyder-env
spyder
.py和.ipynb都是常用的文件,很像.R和.Rmd,所以两个都要用。直接用spyder打开很奇怪,看着就不像python代码。
搜索发现,spyder可以打开ipynb文件,是需要安装插件。
插曲:超级搞笑,查到一些答案说去工具栏找插件管理器,结果没找到,一看就是时效性过了
可是没有插件管理器啊。
继续搜索,还是官方文档香,用conda装就是了。官方说了,这个插件只支持conda装的spyder软件,不支持自己下载安装的spyder软件。👇
安装的方法仍然是命令行,在anaconda promt窗口里运行:
conda install spyder-notebook -c conda-forge
要先显示notebook窗口
然后点一下下图中的notebook
再从右上角打开!(不支持文件窗格双击打开或者左上角打开)
支持rstudio同款布局!
自己调了调字体字号颜色啥的,把字体都调的和Rstudio一样就很顺眼了。
我已经开启了对着R语言学python模式。