安裝python3.7
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
yum install -y libffi-devel zlib1g-dev
yum install zlib* -y
下載Python-3.7.4
[root@localhost ~]# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
tar -xvJf Python-3.7.4.tar.xz
mkdir /usr/local/python3
cd Python-3.7.4
./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl
make && make install
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
python3 -V
pip3 -V
#升級pip
python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade pip
#安裝jupyter
python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org jupyter
[root@localhost ~]#
[root@localhost ~]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
[root@localhost ~]# python3
Python 3.7.4 (default, Jan 27 2021, 18:55:34)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'argon2:$argon2id$v=19$m=10240,t=10,p=8$WO7qKy0At4ibgnThBu0Agw$7VMMXKSxRyu7/xxx'
>>> exit()
[root@localhost ~]#
# vi ~/.jupyter/jupyter_notebook_config.py
# 設置所有IP皆可訪問
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$WO7qKy0At4ibgnThBu0Agw$7VMMXKSxRyu7/xxx'
# 禁止自動打開瀏覽器
c.NotebookApp.open_browser = Flase
# 服務端口
c.NotebookApp.port = 8080
[root@localhost ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]#
#啓動jupyter
jupyter notebook --allow-root
瀏覽器中輸入IP:8080訪問
#安裝ipyparallel
pip3 install ipyparallel
#打開ipyparallel
[root@localhost ~]# ipcluster nbextension enable
Enabling IPython clusters tab
#關閉ipyparallel
[root@localhost ~]# ipcluster nbextension disable
#安裝JupyterHub Install
jupyter nbextension install --sys-prefix --py ipyparallel
jupyter nbextension enable --sys-prefix --py ipyparallel
jupyter serverextension enable --sys-prefix --py ipyparallel
#Start a cluster(https://github.com/ipython/ipyparallel)
ipcluster start
vi startup.sh
nohup jupyter notebook --allow-root &
nohup ipcluster start &
chmod +x startup.sh
./startup.sh
vi test.py
#測試腳本
import os
import ipyparallel as ipp
rc = ipp.Client()
ar = rc[:].apply_async(os.getpid)
pid_map = ar.get_dict()
print(pid_map)
[root@localhost ~]# python3 test.py
{0: 1386, 1: 1387}
[root@localhost ~]#