1. 程式人生 > >在centos7上搭建jupyter lab伺服器

在centos7上搭建jupyter lab伺服器

安裝jupyter lab

  • 安裝setuptools
  • 安裝pip
  • 安裝gcc

yum install gcc

  • 安裝python-devel

yum install python-devel

  • 安裝jupyterlab

pip install jupyterlab

新增遠端訪問jupyter notebook的功能

  • 生成配置檔案

jupyter notebook --generate-config

  • 開啟ipython,建立一個密文的密碼,以123456為例

ipython from notebook.auth import passwd passwd() Enter password: 123456 Verify password: 123456 ‘sha1:e00ee9ab9a42:22e8c0dc771612348eeee698cde8ec77fba42e7f’ exit()

  • 把生成的密文‘sha:xx…’複製下來
  • 修改預設配置檔案 vi ~/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip=’*’ c.NotebookApp.password = u’sha1:e00ee9ab9a42:22e8c0dc771612348eeee698cde8ec77fba42e7f’ c.NotebookApp.open_browser = False c.NotebookApp.port =8888

防火牆開放8888埠

firewall-cmd --zone=public --add-port=8888/tcp --permanent systemctl restart firewalld.service iptables -L -n

關閉firewall(不推薦)

systemctl stop firewalld.service systemctl disable firewalld.service firewall-cmd --state

安裝python3.62和jupyterlab的python3直譯器

yum -y groupinstall “Development tools” yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel wget

https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz tar -xvJf Python-3.6.2.tar.xz cd Python-3.6.2 ./configure --prefix=/usr/local/python3 make && make install ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 cd ~ pip3 install --upgrade pip python3 -m pip install ipykernel python3 -m ipykernel install --user

安裝R和jupyterlab的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’)) devtools::install_github(‘IRkernel/IRkernel’) IRkernel::installspec()

啟動jupyter notebook:

nohup jupyter lab --allow-root &

登入jupyter lab