{"id":2043,"date":"2026-02-24T12:47:59","date_gmt":"2026-02-24T04:47:59","guid":{"rendered":"http:\/\/www.huerpu.cc:7000\/?p=2043"},"modified":"2026-02-24T12:56:02","modified_gmt":"2026-02-24T04:56:02","slug":"ubuntu-24-04%e9%85%8d%e7%bd%ae%e5%ae%89%e8%a3%85-jupyter-notebook%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/www.huerpu.cc:7000\/?p=2043","title":{"rendered":"Ubuntu 24.04\u914d\u7f6e\u5b89\u88c5 Jupyter Notebook\u6559\u7a0b"},"content":{"rendered":"<h1>Ubuntu 24.04\u914d\u7f6e\u5b89\u88c5 Jupyter Notebook\u6559\u7a0b<\/h1>\n<pre><code class=\"language-shell\"># \u66f4\u65b0\u7cfb\u7edf\u5305\nsudo apt update && sudo apt upgrade -y\n\n# \u5b89\u88c5 Python3\u3001pip \u548c\u865a\u62df\u73af\u5883\u5de5\u5177\nsudo apt install python3 python3-pip python3-venv -y\n\n# 1. \u521b\u5efa Jupyter \u865a\u62df\u73af\u5883\u76ee\u5f55\uff08\u53ef\u81ea\u5b9a\u4e49\u8def\u5f84\uff0c\u8fd9\u91cc\u4ee5 \/opt\/hep-jupyter \u4e3a\u4f8b\uff09\nsudo mkdir -p \/opt\/hep-jupyter\nsudo chown $USER:$USER \/opt\/hep-jupyter  # \u5c06\u76ee\u5f55\u6240\u6709\u6743\u8d4b\u4e88\u5f53\u524d\u7528\u6237\ncd \/opt\/hep-jupyter\n\n# 2. \u521b\u5efa Python \u865a\u62df\u73af\u5883\npython3 -m venv venv\n\n# 3. \u6fc0\u6d3b\u865a\u62df\u73af\u5883\nsource venv\/bin\/activate\n\nsudo apt install nodejs npm -y\n# 4. \u5b89\u88c5 Jupyter Notebook\uff08\u6216 JupyterLab\uff0c\u6839\u636e\u9700\u6c42\u9009\u62e9\uff09\n# pip install jupyter notebook  # \u7ecf\u5178 Jupyter Notebook\npip install jupyterlab  # \u5982\u679c\u4f60\u66f4\u4e60\u60ef JupyterLab\n\n# \u751f\u6210 Jupyter Server \u914d\u7f6e\u6587\u4ef6\uff08JupyterLab \u901a\u7528\uff09\njupyter server --generate-config\n\n# \u4e3a JupyterLab \u8bbe\u7f6e\u767b\u5f55\u5bc6\u7801\njupyter server password\n\n# \u521b\u5efa\u65b0\u7684\u5de5\u4f5c\u76ee\u5f55 \/usr\/software\/jupyter\/\nsudo mkdir -p \/usr\/software\/jupyter\n# \u5c06\u76ee\u5f55\u6240\u6709\u6743\u8d4b\u4e88\u5f53\u524d\u7528\u6237\uff08\u907f\u514d\u6743\u9650\u95ee\u9898\uff09\nsudo chown $USER:$USER \/usr\/software\/jupyter\n\nvim \/root\/.jupyter\/jupyter_server_config.py\n# JupyterLab \u6838\u5fc3\u914d\u7f6e\uff08root \u7528\u6237\u4e13\u7528\uff09\nc.ServerApp.ip = '0.0.0.0'\nc.ServerApp.port = 1050\nc.ServerApp.open_browser = False\nc.ServerApp.root_dir = '\/usr\/software\/jupyter'\nc.ServerApp.token = ''\nc.ServerApp.allow_root = True\n# \u53ef\u9009\uff1a\u5173\u95ed\u5b89\u5168\u68c0\u67e5\uff08\u907f\u514d root \u8fd0\u884c\u7684\u6743\u9650\u8b66\u544a\uff09\nc.ServerApp.allow_remote_access = True\nc.ServerApp.disable_check_xsrf = True\n\nvim \/etc\/systemd\/system\/hep-jupyter.service\n\n[Unit]\nDescription=HEP JupyterLab Service\nAfter=network.target\n\n[Service]\nType=simple\nUser=root\nGroup=root\n# \u52a0\u8f7d\u5168\u5c40\u73af\u5883\u53d8\u91cf\uff08\u89e3\u51b3 JDK\/Python \u73af\u5883\u53d8\u91cf\u95ee\u9898\uff09\nEnvironmentFile=-\/etc\/profile\nWorkingDirectory=\/opt\/hep-jupyter\nEnvironment=\"PATH=\/opt\/hep-jupyter\/venv\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\"\n\n# \u542f\u52a8\u547d\u4ee4\uff08\u7b80\u5316\uff0c\u65e0\u9700\u624b\u52a8\u6307\u5b9a config\uff0cLab \u4f1a\u81ea\u52a8\u8bfb\u53d6 \/root\/.jupyter\/jupyter_server_config.py\uff09\nExecStart=\/opt\/hep-jupyter\/venv\/bin\/jupyter lab --no-browser --ip=0.0.0.0 --port=1050 --notebook-dir=\/usr\/software\/jupyter\n\n# \u91cd\u542f\u7b56\u7565\uff08\u589e\u52a0\u8d85\u65f6\uff0c\u907f\u514d\u9891\u7e41\u91cd\u542f\uff09\nRestart=on-failure\nRestartSec=5\nTimeoutSec=30\n\n[Install]\nWantedBy=multi-user.target\n\n# 1. \u91cd\u65b0\u52a0\u8f7d systemd \u914d\u7f6e\nsudo systemctl daemon-reload\n\n# 2. \u542f\u52a8 hep-jupyter \u670d\u52a1\nsudo systemctl start hep-jupyter.service\n\n# 3. \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\nsudo systemctl enable hep-jupyter.service\n\n# 4. \u67e5\u770b\u670d\u52a1\u72b6\u6001\uff08\u786e\u8ba4\u662f\u5426\u8fd0\u884c\u6210\u529f\uff09\nsudo systemctl status hep-jupyter.service\n\nsudo ufw allow 1050\/tcp\n\nhttp:\/\/<\u4f60\u7684\u670d\u52a1\u5668IP>:1050\n\n# \u505c\u6b62\u670d\u52a1\nsudo systemctl stop hep-jupyter.service\n\n# \u91cd\u542f\u670d\u52a1\nsudo systemctl restart hep-jupyter.service\n\n# \u67e5\u770b\u670d\u52a1\u65e5\u5fd7\nsudo journalctl -u hep-jupyter.service -f\n\n# \u5b89\u88c5\u76ee\u5f55\u5bfc\u822a\u63d2\u4ef6\uff08toc = Table of Contents\uff09\npip install jupyterlab-toc\n\n# \u5b89\u88c5 LaTeX \u6269\u5c55\u652f\u6301\npip install jupyterlab-latex\n\n# \u91cd\u542f\u670d\u52a1\u751f\u6548\nsudo systemctl restart hep-jupyter.service\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu 24.04\u914d\u7f6e\u5b89\u88c5 Jupyter Notebook\u6559\u7a0b # \u66f4\u65b0\u7cfb\u7edf\u5305 sudo apt up [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-2043","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/2043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2043"}],"version-history":[{"count":2,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/2043\/revisions"}],"predecessor-version":[{"id":2045,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/2043\/revisions\/2045"}],"wp:attachment":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2043"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}