linux 安装anaconda并实现本地连接

Posted _less is more

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 安装anaconda并实现本地连接相关的知识,希望对你有一定的参考价值。

环境:Xshell,用ssh连接centos7

1、下载.sh文件

wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh

之所以不安装Anaconda3-2022.05-Linux-x86_64.sh是因为GLIBC版本达不到要求,如下
WARNING: The installer is not compatible with the version of the Linux distribution installed on your system. The version of GLIBC is no longer supported. Found version 2.14, which is less than 2.17 Aborting installation.

2、启动此二进制.sh

bash Anaconda3-2020.02-Linux-x86_64.sh

回车,再长按回车看完terms后输入yes,然后根据需要设置安装目录,如下所示

Anaconda3 will now be installed into this location:
/ifshome/lzhong/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/ifshome/lzhong/anaconda3] >>> /ifs/loni/faculty/shi/spectrum/Student_2020/lzhong/env/anaconda3

等待几分钟安装,询问是否初始化,输入yes

安装完成

3、退出terminal,重新打开,或者直接source ~/.bashrc

输入conda -V查看版本

此时可以看到,我安装的anaconda是在我这个用户的目录下的,配置文件也是写入的~/.bashrc,只和我当前使用的用户有关联

此时输入which python,可以看到python已经不是系统的那个python,而是我刚刚安装的anaconda下的python

4、创建新的虚拟环境

conda create -n fsl python=3.7

创建完成后,查看conda下有哪些python环境

(base) -bash-4.2$ conda env list

进入fsl

conda activate fsl

5、端口映射

将本地的某个端口映射到远程Linux服务器的某个端口,因为我用的是学校服务器,所以首先开了VPN

方法一

端口映射可以用Xshell的ssh隧道实现,但Xshell还需要Xmanager来处理X11请求,但似乎只能用试用版。

方法二

这里我采用直接用Windows cmd 的 ssh 连接服务器(可能需要提前配置ssh)

我的目标主机是cranium-dev-5.ini.usc.edu,所以将本地的12345通过local的模式映射到cranium-dev-5.ini.usc.edu的1111

ssh lzhong@cranium-dev-5.ini.usc.edu -L 127.0.0.1:12345:127.0.0.1:1111

注:这里的127.0.0.1:12345:127.0.0.1:1111没有问题,因为分别对应了源和目标主机各自的本地ip和端口

登陆服务器后,打开jupyter lab,设置端口为1111

jupyter lab --port 1111

然后就能本地访问jupyter lab了(通过12345端口)

不过如果发现连接不上,可能是根本没有权限,像我一样:


那就没辙了,lab不会给我权限

以上是关于linux 安装anaconda并实现本地连接的主要内容,如果未能解决你的问题,请参考以下文章

实用教程Windows远程服务器安装anaconda,开放端口并在本地访问Jupyter notebook

群晖安装Anaconda3并开机启动jupyter-notebook

云服务器上安装Anaconda并运行python

云服务器上安装Anaconda并运行python

腾讯云使用:本地连接服务器并安装宝塔Linux面板

云服务器上安装Anaconda并运行python