说明:最近看上了Jupyter Lab,比之前搭建的jupyter notebook体验更好,打算把他装在阿里云送的突发型2c4g服务器上,便于我写程序。
阿里云控制台
登陆阿里云控制台,选择centos7.7镜像,安装,开放安全组端口。
Xshell
安装python3
首先先更新系统
yum update -y
进入Xshell,准备安装python3
先安装必要环境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget libffi-devel
备份现有的python2
cd /usr/bin
mv python python.bak
mv pip pip.bak
使用淘宝源下载并编译安装python3。具体可以看我之前写的文章
cd ~ && wget https://npm.taobao.org/mirrors/python/3.8.2/Python-3.8.2.tar.xz
tar -xvJf Python-3.8.2.tar.xz
cd Python-3.8.2
#指定安装路径
./configure prefix=/usr/local/python3
#编译并安装
make && make install
做一条软连接,将python3指向python,pip3指向pip:
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
修改yum配置
vim /usr/bin/yum
按insert,把头部的 #! /usr/bin/python 修改为 #! /usr/bin/python2
同理修改urlgrabber-ext-down 文件,把头部的 #! /usr/bin/python 修改为 #! /usr/bin/python2
vim /usr/libexec/urlgrabber-ext-down
输入i进入编辑模式,按esc键退出编辑模式
输入:/xxx 查找xxx
输入:wq 保存退出
方向键控制光标位置
输入数字要使用字母上面那行数字
不要使用键盘右边的数字小键盘!
安装nodejs、npm和yarn
curl --silent --location https://rpm.nodesource.com/setup_12.x | bash -
sudo yum install -y nodejs
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install -y yarn
安装jupyterlab
安装一些包
yum groupinstall "Development Tools" -y
升级pip并安装ipython和jupyter
pip install --upgrade pip
pip install ipython jupyterlab
ln -sv /usr/local/python3/bin/ipython /usr/bin/
ln -sv /usr/local/python3/bin/jupyter /usr/bin/
创建Jupyter配置文件,生成在/root/.jupyter/jupyter_notebook_config.py
cd ~
jupyter lab --generate-config
开ipython,生成sha1的密码,并保存输出的sha1.如下:
ipython
from notebook.auth import passwd
passwd()
#Enter password
#output sha1:b19ff9adaa17:d2134ea473aa63718336ed0fb297f8bf44a9c783.
exit()
编辑配置文件
vim /root/.jupyter/jupyter_notebook_config.py
找个地方插入,
c.NotebookApp.password = 'sha1:<your-sha1-hash-value>'
c.NotebookApp.port = 8000
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.allow_root = True
c.NotebookApp.allow_remote_access = True
c.NotebookApp.notebook_dir = '/root/lab'
创建文件夹
mkdir /root/lab
mkdir /root/build
安装R语言内核(可选)
yum -y install epel-release
yum -y install R
yum -y install curl
yum -y install libcurl libcurl-devel
yum -y install libxml2 libxml2-devel
R
install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
install.packages("IRkernel")
IRkernel::installspec(user = FALSE)
安装julia语言内核(可选)
mkdir /usr/local/julia
cd /usr/local/julia
wget https://mirrors.ustc.edu.cn/julia/releases/v1.4/julia-1.4.1-linux-x86_64.tar.gz
tar -zxvf julia-1.4.1-linux-x86_64.tar.gz
mv julia-1.4.1/* /usr/local/julia
rm -rf julia-1.4.1
ln -s /usr/local/julia/bin/julia /usr/bin/julia
进入julia
julia
]
add IJulia
exit()
安装JavaScript内核(可选)
npm install -g ijavascript
ijsinstall --spec-path=full
安装插件(可选)
pip install ipyleaflet
jupyter nbextension enable --py --sys-prefix ipyleaflet
pip install bqplot
jupyter nbextension enable --py --sys-prefix bqplot
pip install pythreejs
jupyter nbextension enable --py --sys-prefix pythreejs
pip install ipyvolume
jupyter nbextension enable --py --sys-prefix ipyvolume
pip install k3d
jupyter nbextension enable --py --sys-prefix k3d
pip install gmaps
jupyter nbextension enable --py --sys-prefix gmaps
pip install nglview
jupyter nbextension enable --py --sys-prefix nglview
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-leaflet bqplot jupyter-threejs ipyvolume jupyter-matplotlib
jupyter labextension install jupyterlab-drawio @jupyterlab/toc @jupyterlab/latex @jupyterlab/shortcutui
后台启动
nohup jupyter lab > jupyterlab.log &
删除内核
jupyter kernelspec list
jupyter kernelspec remove 内核名
卸载插件
jupyter labextension list
jupyter labextension uninstall 插件名
版权声明:本文为原创文章,版权归 Helo 所有。
本文链接:https://www.ishelo.com/archives/261/
商业转载请联系作者获得授权,非商业转载请注明出处。