快速搭建Jupyter notebook远程访问
W35周两天时间, 终于将阿里服务器上的东西搬到了腾讯云。顺便记录下搬运Jupyterlab/notebook挖的坑。
Jupyterlab是 jupyter notebook 后继版本, 有做比较多的扩展。
配置Python环境
安装Python Venv
使用python配置环境, 最容易的就是venv了, 所以我们就可以建立jupyter的用户,然后直接创建venv就可以了。创建venv,就相当于单独创建了一个python3环境, 不会跟系统的python发生冲突(尤其对于版本有需求的特别友好)。
python3 -m venv /path/of/venv
Ubuntu下可以直接source, windows 则直接activate即可
source /path/to/venv/bin/activate
相对应的,如果取消当前venv环境
deactivate
安装Jupyterlab
安装jupyterlab前, 需要先确认pip3有没有安装, 如果没有安装就可以先安装pip3
sudo apt-get install python3-pip
确认下版本, 如需要更新, 执行下面命令
python3 -m pip install --upgrade pip
建议配置pip 国内软件源,体验非一般的赶脚。
Pipe3 源更新
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装Jupyter
pip3 install jupyter
安装完成后, 可以简单测试
jupyter notebook
然后确保内容是否正确。
生成Jupyter密码
-
- 生成默认配置
- 设置访问密码
- 配置文件修改
#jupyter notebook --generate-config #~/.jupyter/jupyter_notebook_config.py
生成密码需要用到notebook.auth的passwd函数,进入IPython,然后调用passwd函数。将输出内容贴到配置文件即可。
In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: 'xxxxxxxxxxxxxxxxx'
Jupyter Conf配置
主要配置信息
c.NotebookApp.ip='*' c.NotebookApp.password = u'sha:ce...刚才复制的那个密文' c.NotebookApp.open_browser = False c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口 c.NotebookApp.allow_remote = true # 远程访问务必配置的信息,否则外网无法访问 c.NotebookApp.keyfile = '/............/cert.key' c.NotebookApp.certfile = '/.........../cert.pem'
如果需要配置SSL, 则需要额外配置keyfile/certfile两项。
配置完成后, 可以执行notebook 确认是否运行正常
jupyter notebook
服务配置
[Unit] Description=jupyter service After=network.target remote-fs.target nss-lookup.target [Service] Type=simple PIDFile=/run/jupyter.pid User=jupyter_user_name ExecStart=/bin/bash -c "source /path/to/venv/bin/activate && jupyter lab" ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
保存为jupyter.service,然后放到/etc/systemd/system/jupyter.service.透过systemd enable jupyter, 并启动
sudo systemctl daemon-reload sudo systemctl enable jupyter sudo systemctl start jupyter sudo systemctl status jupyter //查看jupyter 启动信息
如需要安装jupyter lab插件, 则需要安装nodejs
因为ubuntu 18.04 上预装的nodejs版本过低, 可以直接从源码构建并安装
wget 获取到node.js源码包,然后编译并安装
sudo ./configure sudo make sudo make install
体验jupyterlab的强大!
I am always browsing online for posts that can assist me. Thx!
I enjoy you because of all of your effort on this blog. Ellie enjoys conducting internet research and it’s easy to see why. All of us hear all about the compelling manner you create efficient ideas by means of the blog and as well cause contribution from other ones about this article and my child is being taught a great deal. Enjoy the remaining portion of the new year. You’re the one carrying out a fantastic job.
I wanted to put you the tiny remark to be able to say thanks once again for your personal marvelous principles you’ve featured in this article. It is quite seriously generous of people like you to give openly just what many individuals might have marketed as an e book to generate some dough for themselves, most notably given that you could possibly have done it if you ever decided. These principles as well served to be a fantastic way to fully grasp other people have similar fervor much like my own to know the truth many more pertaining to this issue. I am certain there are millions of more fun opportunities in the future for individuals who looked over your blog post.
I am also commenting to let you know of the helpful encounter my friend’s daughter found reading through your web page. She figured out numerous issues, not to mention what it’s like to have an amazing giving mood to have men and women really easily have an understanding of selected impossible subject areas. You really exceeded our own expectations. Many thanks for imparting the interesting, safe, explanatory and even easy thoughts on the topic to Janet.
I needed to draft you one little bit of observation so as to say thanks once again for your lovely opinions you’ve documented in this article. It is quite remarkably generous of people like you to allow extensively all that a lot of people could possibly have distributed as an e-book to earn some cash for their own end, especially considering the fact that you could have done it if you considered necessary. The good tips also acted like a easy way to be sure that most people have a similar dreams just like mine to grasp a whole lot more in respect of this condition. I’m certain there are lots of more enjoyable moments ahead for individuals that find out your blog.
I simply wanted to thank you so much once more. I am not sure the things that I would’ve sorted out without the type of strategies revealed by you over that situation. It truly was an absolute horrifying matter in my opinion, however , spending time with the very specialised style you resolved that made me to leap over gladness. I will be happy for this advice and believe you are aware of a powerful job that you’re accomplishing educating many others all through a blog. I’m certain you’ve never come across all of us.
My husband and i ended up being absolutely delighted Chris could complete his homework from the ideas he came across from your own site. It’s not at all simplistic just to be giving away helpful hints that many people could have been making money from. And we discover we’ve got the blog owner to appreciate because of that. All the explanations you have made, the simple web site navigation, the relationships you will help foster – it’s got many incredible, and it’s really helping our son in addition to the family know that the matter is excellent, which is quite mandatory. Thank you for everything!
I’m just commenting to let you be aware of of the extraordinary discovery my cousin’s daughter experienced going through your site. She even learned lots of issues, most notably how it is like to have a very effective giving mindset to have many others just gain knowledge of chosen extremely tough matters. You really did more than our desires. Many thanks for distributing the important, healthy, educational and as well as easy thoughts on the topic to Gloria.
I enjoy you because of all of your effort on this blog. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all about the compelling manner you create functional ideas by means of the blog and as well cause contribution from other ones about this article and my child is being taught a great deal. Enjoy the remaining portion of the new year. You’re the one carrying out a first class job.
Great info and straight to the point. I am not sure if this is in fact the best place to ask but do you folks have any thoughts on where to get some professional writers? Thanks 🙂 https://livermedi.com liver failure meds
Useful information. Lucky me I discovered your web site by accident, and I’m stunned why this coincidence didn’t happened earlier! I bookmarked it. https://stomachulcersmedi.com buy stomach ulcers medication
I am constantly looking online for posts that can facilitate me. Thx! https://alzheimermedi.com buy Alzheimer medications
You got a very fantastic website, Gladiolus I detected it through google. https://tuberculosismedi.com tuberculosis threatment
I am constantly looking online for posts that can aid me. Thank you! https://hivmedi.com best hiv drugs
I am constantly looking online for posts that can aid me. Thank you! https://myastheniamedi.com best myasthenia medication
Wonderful site. A lot of useful information here. I’m sending it to some pals ans also sharing in delicious. And obviously, thank you on your effort! https://parkinsonmedi.com best parkinson drugs
You meet your handsome guy or beautiful gal at a restaurant for your first date. Could they be the one? They don’t look crazy or anything.
But instead of greeting you or even acknowledging you, your date just starts talking.
카지노사이트
Did you know they have a co-worker named Mr. Buttons? Did you know they have a peanut allergy?
And yet, every day, thousands of comments are written that do not bother to acknowledge the post’s author in any way, shape, or form.
퍼스트카지노