• Linux服务器安装Anaconda 配置远程jupyter lab使用虚拟环境


    参考的博客:
    Linux服务器安装Anaconda 并配置远程jupyter lab
    anaconda配置远程访问jupyter,并创建虚拟环境
    理解和创建:Anaconda、Jupyterlab、虚拟环境、Kernel

    下边是正文了。
    https://www.anaconda.com/download是官网网址,可以下载最新版本。
    在这里插入图片描述

    在这里插入图片描述
    https://repo.anaconda.com/archive/可以下载以前的版本,注意需要选择自己需要的版本。

    在这里插入图片描述

    wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh下载安装脚本。
    在这里插入图片描述

    chmod u+x Anaconda3-2023.03-1-Linux-x86_64.sh给shell脚本加上执行权限。
    在这里插入图片描述
    bash Anaconda3-2023.03-1-Linux-x86_64.sh开始安装,按一下Enter键。
    在这里插入图片描述
    然后需要一直按Enter键,直到出现"Do you accept the license terms? [yes|no]"这个提示词,然后输入yes,按下Enter键,之后输入需要安装的目录,我这里选择的是“/home/anaconda3”。

    在这里插入图片描述

    输入yes表明需要安装时进行初始化。
    在这里插入图片描述
    source ~/.bashrc激活基本环境。
    在这里插入图片描述
    重新打开远程登录,直接进入到基本环境里。
    在这里插入图片描述

    conda create -n jupyterlabuse python=3.10.9创建一个虚拟环境。
    在这里插入图片描述

    输入y
    在这里插入图片描述

    完成之后,如下图:
    在这里插入图片描述
    conda activate jupyterlabuse激活jupyterlabuse的环境。
    在这里插入图片描述

    jupyter lab --generate-config执行之后,发现报:

    -bash: jupyter: command not found
    
    • 1

    在这里插入图片描述

    pip install jupyterlab -i https://pypi.mirrors.ustc.edu.cn/simple安装jupyterlab
    在这里插入图片描述
    安装成功如下:
    在这里插入图片描述

    jupyter lab --generate-config生成配置文件。
    在这里插入图片描述
    使用ipython,然后输入from jupyter_server.auth import passwd;passwd(),之后输入两次一样的密码。
    在这里插入图片描述
    把单引号里边的argon2:$argon2id$v=19$m=10240,t=10,p=8$TnfU106Z+qRr7ubwSg$/Phki8t73l6+8PBfSnY4ygtbwuP8NNhUsV5MFvfxUmI保存好,因为接下来需要把它输入到/root/.jupyter/jupyter_lab_config.py里边。

    然后输入exit()按下回车退出ipython。
    在这里插入图片描述

    使用sudo cat <>/root/.jupyter/jupyter_lab_config.py把下边的内容保存到/root/.jupyter/jupyter_lab_config.py里边。

    c.ServerApp.allow_remote_access = True
    c.ServerApp.ip = '0.0.0.0'
    c.ServerApp.open_browser = False  
    c.ServerApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$TnfU106Z+qRr7ubwSg$/Phki8t73l6+8PBfSnY4ygtbwuP8NNhUsV5MFvfxUmI' # 上面保存的密码
    c.ServerApp.port = 12345 # 服务器的端口号,下边需要使用这个端口号
    
    • 1
    • 2
    • 3
    • 4
    • 5

    每输入一行就按一下回车键。
    在这里插入图片描述

    tail -5 /root/.jupyter/jupyter_lab_config.py查看一下上边输入的内容。
    在这里插入图片描述

    nohup jupyter lab --allow-root &后台启动jupyter lab,然后按一下回车键Enter
    在这里插入图片描述

    python -m ipykernel install --user --name jupyterlabuse --display-name "usertest"直接在环境里执行下面的代码来手动添加kernel进jupyter lab。

    在这里插入图片描述

    conda deactivate先退出虚拟环境。
    在这里插入图片描述
    ps -aux | grep "jupyter-lab"找出来对应的进程,然后使用kill -9 进程号杀死进程。
    在这里插入图片描述

    conda activate jupyterlabuse重新激活jupyterlabuse虚拟环境,nohup jupyter lab --allow-root &后台启动jupyter lab

    在这里插入图片描述
    ip:port/lab端口号输入到浏览器中,比如我这里在浏览器中输入192.168.53.240:12345/lab
    在这里插入图片描述
    然后按下回车,就会自动跳转到192.168.53.240:12345/login?next=%2Flab
    在这里插入图片描述

    输入密码就可以进入了,选择自己刚刚创建的名为usertest的Kernel。
    在这里插入图片描述

    点击“Select”。
    在这里插入图片描述

    右上角变成了“usertest”
    在这里插入图片描述

    此文章为9月Day 17学习笔记,内容来源于极客时间《零基础实战机器学习》

  • 相关阅读:
    JVM常见面试题
    计算机毕业设计Java网上投稿管理系统(源码+系统+mysql数据库+Lw文档)
    qt学习之旅--QToolBar的使用(一)
    c语言,c++,java和python这些语言有何区别?编译型编程语言编译语言,解释型编程语言解释型语言
    Web Tour Server窗口闪现
    MySQL学习笔记-4.数据更新时的性能问题
    解决Tmux提示的size x*x from a smaller client窗口缩放问题
    ESP8266-Arduino编程实例-BMA250加速度传感器驱动
    zabbix监控方式
    03【MyBatis参数深入】
  • 原文地址:https://blog.csdn.net/qq_42108074/article/details/131214960