一、安装前准备
请浏览“安装多版本python 建立虚拟环境”,建立虚拟python环境。
假设原python路径为/usr/local/python3,虚拟环境将建立在/mpy/python39。
/usr/local/python3/bin/python3 -m venv /mypy/python39
进入虚拟Python主环境
source /mypy/python39/bin/activate
python --version
pip list
二、下载升级安装包
请浏览“离线安装Python第三方库及依赖库”,离线下载升级安装包。
1.基本包
pip3 download pip setuptools -d /software/pip
pip3 install --no-index --find-links=/software/pip --upgrade pip setuptools
2.Jupyterlab包
pip3 download jupyterlab -d /software/jupyterlab
pip3 install --no-index --find-links=/software/jupyterlab jupyterlab
三、设置Jupyterlab
1.设定密码
jupyter lab password
2.配置参数
vim /root/.jupyter/jupyter_server_config.json
“password”行数据保持不变,添加其他行数据。
{
"ServerApp": {
"password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$rQAH6yOcwklwv8NwFCmA" ,
"ip" : "*" ,
"port" : 8080 ,
"open_browser" : false ,
"notebook_dir" : "/root" ,
"allow_root": true
}
}
四、安装中文插件
pip3 download jupyterlab-language-pack-zh-CN -d /software/jupyter_extension
pip3 install --no-index --find-links=/software/jupyter_extension jupyterlab-language-pack-zh-CN
五、安装Jupyterlab服务
1.测试Jupyterlab
jupyter lab
2.创建jupyter.service
文件
vim /etc/systemd/system/jupyter.service
[Unit]
Description=jupyterlab
After=network.service
[Service]
ExecStart=/mypy/python39/bin/jupyter lab
[Install]
WantedBy=default.target
3.安装服务
systemctl start jupyter
systemctl enable jupyter
六、安装多内核环境
1.设定虚拟环境
#激活虚拟环境
/usr/local/python310/bin/python3 -m venv /mypy/python310
source /mypy/python310/bin/activate
#安装升级包
pip download pip setuptools -d /software/pip
pip install --no-index --find-links=/software/pip --upgrade pip setuptools
#安装ipykernel
pip download ipykernel -d /software/ipykernel
pip install --no-index --find-links=/software/ipykernel ipykernel
2.安装Jupyterlab的多内核环境
python -m ipykernel install --user --name python310 --display-name "Python-3.10.7"
3.检查多内核设置
#进入主虚拟环境
source /mypy/python39/bin/activate
#查验版本信息
python --version
pip list
jupyter kernelspec list