jupyter部署安装

 sudo /usr/bin/python3 -m ipykernel install --name python3.6.8

sudo pip373 install ipykernel

 sudo python373 -m ipykernel install --name python3.7.3
 

python373 -m ipykernel install --name python373
ipython kernelspec list

sc create myjupyterservice binpath="D:\apply\Python373\Scripts\jupyter-notebook --config=V:/my_work/jupyter/config/jupyter_notebook_config.py  --no-browser -y --allow-root" displayname="my jupyter service " start=auto


C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

D:\apply\Python373\Scripts\jupyter-notebook --config=V:/my_work/jupyter/config/jupyter_notebook_config.py  --no-browser -y --allow-root > d:\mywork\jupyter\jupyter.log 2>&1
D:\apply\Python373\Scripts\jupyter notebook --no-browser -y --allow-root > d:\mywork\jupyter\jupyter.log 2>&1

mkdir -p d:\mywork\jupyter\files 
    pip373 install --index-url=https://mirrors.huaweicloud.com/repository/pypi/simple --trusted-host=mirrors.huaweicloud.com ipykernel jupyter jupyterlab jupyter_contrib_nbextensions jupyter_nbextensions_configurator tqdm jupyterthemes autopep8
    D:\apply\Python373\Scripts\jupyter contrib nbextension install
    D:\apply\Python373\Scripts\jupyter nbextensions_configurator enable
    D:\apply\Python373\Scripts\jupyter nbextension enable codefolding/main
    D:\apply\Python373\Scripts\jupyter nbextension enable code_prettify/code_prettify
    D:\apply\Python373\Scripts\jupyter nbextension enable collapsible_headings/main
    D:\apply\Python373\Scripts\jupyter nbextension enable equation-numbering/main
    D:\apply\Python373\Scripts\jupyter nbextension enable highlight_selected_word/main
    D:\apply\Python373\Scripts\jupyter nbextension enable navigation-hotkeys/main
    D:\apply\Python373\Scripts\jupyter nbextension enable notify/notify
    D:\apply\Python373\Scripts\jupyter nbextension enable ruler/main
    D:\apply\Python373\Scripts\jupyter nbextension enable scroll_down/main
    D:\apply\Python373\Scripts\jupyter nbextension enable toc2/main
    D:\apply\Python373\Scripts\jupyter nbextension enable comment-uncomment/main
    D:\apply\Python373\Scripts\jupyter nbextension enable execute_time/ExecuteTime
    D:\apply\Python373\Scripts\jupyter nbextension enable export_embedded/main
    D:\apply\Python373\Scripts\jupyter nbextension enable highlighter/highlighter
    D:\apply\Python373\Scripts\jupyter nbextension enable livemdpreview/livemdpreview
    D:\apply\Python373\Scripts\jupyter nbextension enable ruler/edit
    D:\apply\Python373\Scripts\jupyter nbextension enable snippets_menu/main
    D:\apply\Python373\Scripts\jupyter nbextension enable table_beautifier/main
    D:\apply\Python373\Scripts\jupyter nbextension enable codefolding/edit
    D:\apply\Python373\Scripts\jupyter nbextension enable execution_dependencies/execution_dependencies
    D:\apply\Python373\Scripts\jupyter nbextension enable freeze/main
    D:\apply\Python373\Scripts\jupyter nbextension enable python-markdown/main
    D:\apply\Python373\Scripts\jupyter nbextension enable runtools/main
    D:\apply\Python373\Scripts\jupyter nbextension enable spellchecker/main
    D:\apply\Python373\Scripts\jupyter nbextension enable code_prettify/autopep8
    D:\apply\Python373\Scripts\jupyter nbextension enable datestamper/main
    D:\apply\Python373\Scripts\jupyter nbextension enable nbTranslate/main
    D:\apply\Python373\Scripts\jupyter nbextension enable scratchpad/main
    D:\apply\Python373\Scripts\jupyter nbextension enable tree-filter/index
    D:\apply\Python373\Scripts\jupyter notebook --generate-config -y
    /usr/bin/sed -i "s|#c.NotebookApp.notebook_dir = ''|c.NotebookApp.notebook_dir = '/app/jupyter/files/'|g"  /root/.jupyter/jupyter_notebook_config.py
    /usr/bin/sed -i "s|#c.NotebookApp.open_browser = True|c.NotebookApp.open_browser = False|g"  /root/.jupyter/jupyter_notebook_config.py
    /usr/bin/sed -i "s|#c.NotebookApp.ip = 'localhost'|c.NotebookApp.ip = '0.0.0.0'|g"  /root/.jupyter/jupyter_notebook_config.py
    /usr/bin/sed -i "s|#c.NotebookApp.port = 8888|c.NotebookApp.port = 12345|g"  /root/.jupyter/jupyter_notebook_config.py
    /usr/bin/sed -i "s|#c.NotebookApp.allow_remote_access = False|c.NotebookApp.allow_remote_access = True|g"  /root/.jupyter/jupyter_notebook_config.py
    passwd_sha=`/usr/bin/python373 -c "from notebook.auth import passwd;print(passwd('mima'));"`
    /usr/bin/sed -i "s|#c.NotebookApp.password = ''|c.NotebookApp.password = '$passwd_sha'|g"  /root/.jupyter/jupyter_notebook_config.py

/usr/local/python374/bin/jupyter contrib nbextension install
/usr/local/python374/bin/jupyter nbextensions_configurator enable
/usr/local/python374/bin/jupyter nbextension enable codefolding/main
/usr/local/python374/bin/jupyter nbextension enable code_prettify/code_prettify
/usr/local/python374/bin/jupyter nbextension enable collapsible_headings/main
/usr/local/python374/bin/jupyter nbextension enable equation-numbering/main
/usr/local/python374/bin/jupyter nbextension enable highlight_selected_word/main
/usr/local/python374/bin/jupyter nbextension enable navigation-hotkeys/main
/usr/local/python374/bin/jupyter nbextension enable notify/notify
/usr/local/python374/bin/jupyter nbextension enable ruler/main
/usr/local/python374/bin/jupyter nbextension enable scroll_down/main
/usr/local/python374/bin/jupyter nbextension enable toc2/main
/usr/local/python374/bin/jupyter nbextension enable comment-uncomment/main
/usr/local/python374/bin/jupyter nbextension enable execute_time/ExecuteTime
/usr/local/python374/bin/jupyter nbextension enable export_embedded/main
/usr/local/python374/bin/jupyter nbextension enable highlighter/highlighter
/usr/local/python374/bin/jupyter nbextension enable livemdpreview/livemdpreview
/usr/local/python374/bin/jupyter nbextension enable ruler/edit
/usr/local/python374/bin/jupyter nbextension enable snippets_menu/main
/usr/local/python374/bin/jupyter nbextension enable table_beautifier/main
/usr/local/python374/bin/jupyter nbextension enable codefolding/edit
/usr/local/python374/bin/jupyter nbextension enable execution_dependencies/execution_dependencies
/usr/local/python374/bin/jupyter nbextension enable freeze/main
/usr/local/python374/bin/jupyter nbextension enable python-markdown/main
/usr/local/python374/bin/jupyter nbextension enable runtools/main
/usr/local/python374/bin/jupyter nbextension enable spellchecker/main
/usr/local/python374/bin/jupyter nbextension enable code_prettify/autopep8
/usr/local/python374/bin/jupyter nbextension enable datestamper/main
/usr/local/python374/bin/jupyter nbextension enable nbTranslate/main
/usr/local/python374/bin/jupyter nbextension enable scratchpad/main
/usr/local/python374/bin/jupyter nbextension enable tree-filter/index

/usr/local/python374/bin/jupyter notebook --generate-config -y
    sed -i "s|#c.NotebookApp.notebook_dir = ''|c.NotebookApp.notebook_dir = '/home/my/my_works/jupyter/files/'|g"  /home/my/.jupyter/jupyter_notebook_config.py
    sed -i "s|#c.NotebookApp.open_browser = True|c.NotebookApp.open_browser = False|g" "/home/my/.jupyter/jupyter_notebook_config.py"
    sed -i "s|#c.NotebookApp.ip = 'localhost'|c.NotebookApp.ip = '0.0.0.0'|g" "/home/my/.jupyter/jupyter_notebook_config.py"
    sed -i "s|#c.NotebookApp.port = 8888|c.NotebookApp.port = 12345|g" "/home/my/.jupyter/jupyter_notebook_config.py"
    sed -i "s|#c.NotebookApp.allow_remote_access = False|c.NotebookApp.allow_remote_access = True|g" "/home/my/.jupyter/jupyter_notebook_config.py"
    passwd_sha=`/usr/bin/python374 -c "from notebook.auth import passwd;print(passwd('mima'));"`
    sed -i "s|#c.NotebookApp.password = ''|c.NotebookApp.password = '$passwd_sha'|g" "/home/my/.jupyter/jupyter_notebook_config.py"

 


3. sudo vi /etc/systemd/system/myjupyter.service
[Unit]
Description=Jupyter server
ConditionPathExists=/home/my/my_works/jupyter/rc.local
 
[Service]
Type=forking
ExecStart=/home/my/my_works/jupyter/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target

4. vi /home/my/my_works/jupyter/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo "看到这行字,说明添加自启动脚本成功。" > /home/my/my_works/jupyter/logs/myjupyter.log
/usr/local/python374/bin/jupyter-notebook --config=/home/my/my_works/jupyter/config/jupyter_notebook_config.py  --no-browser -y --allow-root >> /home/my/my_works/jupyter/logs/myjupyter.log

exit 0

5、给rc.local加上权限
sudo chmod +x /home/my/my_works/jupyter/rc.local
6、启用服务
sudo systemctl enable myjupyter.service
7、启动服务并检查状态
sudo systemctl start myjupyter.service
sudo systemctl status myjupyter.service
8、重启并检查test.log文件
cat /home/my/my_works/jupyter/logs/myjupyter.log

 

转载于:https://my.oschina.net/mengyoufengyu/blog/3076822

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值