Linux 安装 Anaconda+Jupyter Lab 教程
一、安装Anaconda
注:Xshell连接服务器后可以使用wget命令在线下载Anaconda进行安装,这里使用Xftp上传下载到本机的linux版本的anaconda进行安装。 下载Anaconda: https://www.anaconda.com/products/individual#Downloads 注:下载缓慢可自行搜索镜像源,这里去清华镜像源下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
①、将下载的安装包 Anaconda3-2022.05-Linux-x86_64.sh
上传到服务器;
[root@hombd05 softwares]# ls -l
total 1167676
-rw-r--r--. 1 root root 690850711 Aug 6 10:54 Anaconda3-2022.05-Linux-x86_64.sh
②“bash”命令安装anaconda
bash Anaconda3-2022.05-Linux-x86_64.sh
执行:
Anaconda3 will now be installed into this location:
/root/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/root/anaconda3] >>>
PREFIX=/root/anaconda3
关闭终端重新连接,输入 conda -V
可查看anaconda版本,如未出现版本号,需进行环境变量配置;
[root@hombd05 bin]# conda -V
-bash: conda: command not found
③、环境变量配置 输如 vi /etc/profile
打开环境变量配置文件:
光标移到最后面,添加下面内容,其中 /root/anaconda3
为自己的文件安装路径,#开头的代表本行为注释,可以不用添加
#Anaconda environment
export ANACONDA_HOME=/root/anaconda3
export PATH=$ANACONDA_HOME/bin:$PATH
输入 source /etc/profile
刷新配置文件,输入 conda -V
查看版本
[root@hombd05 bin]# source /etc/profile
[root@hombd05 bin]# conda -V
conda 4.12.0
到此Anaconda安装成功!
二、安装Jupyterlab
1、查看jupyterlab包
[root@hombd05 ~]# conda list | grep 'jupyter'
jupyter 1.0.0 py39h06a4308_7
jupyter_client 6.1.12 pyhd3eb1b0_0
jupyter_console 6.4.0 pyhd3eb1b0_0
jupyter_core 4.9.2 py39h06a4308_0
jupyter_server 1.13.5 pyhd3eb1b0_0
jupyterlab 3.3.2 pyhd3eb1b0_0
jupyterlab_pygments 0.1.2 py_0
jupyterlab_server 2.10.3 pyhd3eb1b0_1
jupyterlab_widgets 1.0.0 pyhd3eb1b0_1
2、安装
conda install jupyterlab
3、生成配置文件
生成配置文件 输入 jupyter lab --generate-config
生成配置文件
[root@hombd05 ~]# jupyter lab --generate-config
Writing default config to: /root/.jupyter/jupyter_lab_config.py
4、生成密码
[root@homaybd05 ~]# ipython
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from jupyter_server.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Passwords do not match.
Enter password:
Verify password:
Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$N6gqemYswdHeswtT404eLw$pWONhPSL7JqDKju27WC1/Sx9VFaF43/EL8Crq8Kx6FQ'
输入的密码为:Jupyter@2022, 使用记事本保存上面生成的一长串的密文;
接下来一行输入exit,回车退出
5、修改配置文件
⑤修改默认配置文件* 注:#开头及后面的内容为注释 输入 vim /root/.jupyter/jupyter_lab_config.py
修改配置文件 光标移到最后一行,并按i进入编辑模式
[root@hombd05 /]# vim /root/.jupyter/jupyter_lab_config.py
# 将ip设置为*,意味允许任何IP访问
c.ServerApp.ip = '*'
# 这里的密码就是上边我们生成的那一串
#c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$N6gqemYswdHeswtT404eLw$pWONhPSL7JqDKju27WC1/Sx9VFaF43/EL8Crq8Kx6FQ'
c.ServerApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$N6gqemYswdHeswtT404eLw$pWONhPSL7JqDKju27WC1/Sx9VFaF43/EL8Crq8Kx6FQ'
# 服务器上并没有浏览器可以供Jupyter打开,新版默认为false
c.ServerApp.open_browser = False
# 监听端口设置为8888或其他自己喜欢的端口
c.ServerApp.port = 8888
# 允许远程访问
c.Server.allow_remote_access = True
# 我们可以修改jupyter的工作目录,也可以保持原样不变,如果修改的话,要保证这一目录已存在
c.ServerApp.notebook_dir = '/jupyter/jupyter_run'
注意,要提前生成工作目录:
mkdir -p /jupyter/jupyter_run
6、启动
配置完成就可以启动啦,启动方式如下:
jupyter lab
# 后台启动方式,只要服务器运行着,jupyter就一直运行
nohup jupyter lab --allow-root > /jupyter/jupyter.log 2>&1 &
启动:
[root@hombd05 /]# nohup jupyter lab --allow-root > /jupyter/jupyter.log 2>&1 &
[1] 19578
[root@hombd05 /]# ps -ef | grep 'jupyter'
root 19578 6867 13 12:04 pts/0 00:00:02 /root/anaconda3/bin/python3.9 /root/anaconda3/bin/jupyter-lab --allow-root
root 20101 6867 0 12:04 pts/0 00:00:00 grep --color=auto jupyter
启动成功! 访问jupyter 打开浏览器输入http://ip:8888/即可访问
输入自己设置的秘密即可进入!
相关文章:
Linux安装Anaconda+Python+Jupyter教程
conda 安装 jupyter lab
为者常成,行者常至
自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)