关于python:Python-数据科学环境搭建jupyterlab

5次阅读

共计 1841 个字符,预计需要花费 5 分钟才能阅读完成。

更新于 2021-11-02

好马配好鞍,Python 开发须要 IDE,或者说高效的编辑器。Pycharm 这种当然是程序员专用的,也是最受欢迎的,但几百兆的安装包也的确臃肿。python 自带的 Idle 扩展性和实用性不佳。我感觉就目前 VS Code 风行趋势(跨平台、高效),有一统天下的可能,而且用它 Python 的数据迷信就会便捷很多。当然大家也可能理解 Anaconda,这个数据迷信的全能选手,但他切实太臃肿了,我写这文章就是为了不必他。

1. 必要的安装包

  • VS Code
  • Python 解释器(win7 最高反对版本为 3.8)
  • Git

给 Python 的 pip 配置国内镜像

Python 之所以弱小,是因为它有很多扩大包。这些包都须要一个叫 pip 的工具来进行治理和装置。

因为某些家喻户晓的起因,咱们须要将 pip 的包装置源改为国内镜像,如果不改,装置会十分慢,甚至可能无奈装置。

国内的源有:

阿里云 https://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣 (douban) https://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/

长期批改:

能够在应用 pip 的时候在前面加上 - i 参数,指定 pip 源。

pip install scrapy -i https://mirrors.aliyun.com/pypi/simple/

永恒批改:

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

应用 pip 装置几个写代码须要的包

这一步并不是必须的。但倡议装置。flake8 和 yapf, 有助于你代码整洁标准

装置 jupyter lab(举荐)或 jupyter notebook

JupyterLab 能够被视作一个加强版的资源管理器 + 交互模式下的 python,他能让咱们可视化地进行一些数据操作。是数据迷信必备的工具。
pip install jupyterlab,有的人电脑是 pip install jupyter-lab

装置 jupyter lab 插件

想要高兴的应用 jupyter lab,须要装置必要的插件,须要一些筹备。

装置 nodejs

https://nodejs.org/zh-cn/down…
win7 最高反对版本为 13.6

  • 首先装置好 nodejs 到本地。
  • npm 设置国内镜像和装置 python 的 nodejs 包
npm config set registry https://registry.npm.taobao.org
npm config get registry
pip install nodejs

装置 yarn

npm install -g yarn
# yarn 设置国内镜像
yarn config set registry https://registry.npm.taobao.org/
yarn config get registry

装置几个罕用插件

# git
pip install jupyterlab-git
jupyter labextension install @jupyterlab/git
# github
jupyter labextension install @jupyterlab/github
# toc
jupyter labextension install @jupyterlab/toc

jupyter lab 运行 R 代码

装置 IRkernel

# 在 R 装置 IRkernel
install.packages('IRkernel') 
IRkernel::installspec()
jupyter labextension install @techrah/text-shortcuts

留神:如果 jupyter lab 无奈装置这个插件,或者失败,能够尝试如下 2 种办法

  1. 在系统命令行装置

先在 R 装置 IRkernel 包

install.packages('devtools')
devtools::install_github('IRkernel/IRkernel')

而后切换到 R 的装置门路运行 R,再装置
IRkernel::installspec()

  1. 在 windows 找到如下门路,如果没有就新建,而后把 IRkernel 的文件复制到外面

正文完
 0