Vscode远程服务器虚拟环境使用jupyter暨Jupyter远程访问

一、首先关于Jupyter的那些插件是一定要安装的(当然包括Python)

我的就这些,也不知道啥时候装的,可能有的没用吧

二、安装相应的库

当然首先得激活相应的需要的环境,这里不再赘述

juputer库不能少吧(相信已经安装过了吧)

pip install jupyter
pip install ipykernel

三、添加jupyter 的kernel以及选择相应的环境

python -m ipykernel install --name 虚拟环境名

虚拟环境名用自己喜欢的就好,这时候随便打开一个ipynb文件,点击右上角的Slect Kernel(已经选择过环境的是当前Python版本)

依次点击Select Another Kernel ->Jupyter Kernel,这时候就能看到刚才创建的Kernel了

但是!这个地方我发现偶尔会有问题(当然没问题就没必要往下面折腾远程访问了),浏览器使用似乎更靠谱一些,然而在服务器上没有UI怎么办?

四、Jupyter远程访问

我们可以注意到,默认监听的ip是localhost,是无法映射出去的,需要更改监听IP为0.0.0.0,经过查阅资料,需要先生成配置文件

jupyter notebook --generate-config

配置文件位置会返回的

比如Writing default config to: /home/q/.jupyter/jupyter_notebook_config.py

然后在这个配置文件中写下

c.ServerApp.allow_remote_access = True  # 开启远程访问
c.ServerApp.ip = '0.0.0.0' #Jupyter监听的IP

这样就可以通过ip+端口+token的方式在本地访问啦

常见问题

安装库时报错

ERROR: Cannot uninstall '*****'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

此时在安装指令后加上--ignore-installed 即可,如

pip install jupyter --ignore-installed

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Chang乐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值