Linux多用户共用Anaconda环境

0. 下载 Anaconda3

地址:https://www.anaconda.com/download/
这里我下载的是 Anaconda3-2019.03-Linux-x86_64.sh

1.安装Anaconda环境

1. 进入root用户, 安装Anconda

su root
bash Anaconda3-2019.03-Linux-x86_64.sh

注意下面安装路径不要放在默认的 /root/anaconda3 否则其他用户没有访问权限,这里我选择的是/usr/local/anaconda3

Do you accept the license terms? [yes|no]
Please answer ‘yes‘ or ‘no‘:‘
>>> yes
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] >>> /usr/local/anaconda3
PREFIX=/usr/local/anaconda3
installing: python-3.7.3-h0371630_0 ...

2.创建anaconda用户组

groupadd anaconda

3. 添加用户到用户组

adduser <username> anaconda
添加结束通过 `vim /etc/group‘在最后可以查看用户组和用户

4. 移交目录管理权

chgrp -R anaconda /usr/local/anaconda3

5. 设置读写权限

chmod 770 -R /usr/local/anaconda3

6. 设置组继承

chmod g+s /usr/local/anaconda3

7. 设置子目录组继承

chmod g+s find /usr/local/anaconda3/ -type d

8. 关闭共享环境的写入权限

chmod g-w /usr/local/anaconda3/envs

9.root用户下启动anaconda环境

source /usr/local/anaconda3/bin/activate

10. 创建共享环境

conda create -n hisense python=3.7

2.配置环境变量

vim /etc/profile
添加:
export PATH=/usr/local/anaconda3/bin:$PATH
source /etc/profile

3.其他用户激活Anaconda环境

1. 切换用户

su hisense

2.查看conda环境

[hisense@Master wx]$ conda info --env
WARNING: The conda.compat module is deprecated and will be removed in a future release.
# conda environments:
#
base                  *  /usr/local/anaconda3
hisense                  /usr/local/anaconda3/envs/hisense

3.激活环境

[hisense@Master /]$ /usr/local/anaconda3/bin/conda init bash
WARNING: The conda.compat module is deprecated and will be removed in a future release.
no change     /usr/local/anaconda3/condabin/conda
no change     /usr/local/anaconda3/bin/conda
no change     /usr/local/anaconda3/bin/conda-env
no change     /usr/local/anaconda3/bin/activate
no change     /usr/local/anaconda3/bin/deactivate
no change     /usr/local/anaconda3/etc/profile.d/conda.sh
no change     /usr/local/anaconda3/etc/fish/conf.d/conda.fish
no change     /usr/local/anaconda3/shell/condabin/Conda.psm1
no change     /usr/local/anaconda3/shell/condabin/conda-hook.ps1
no change     /usr/local/anaconda3/lib/python3.7/site-packages/xonsh/conda.xsh
no change     /usr/local/anaconda3/etc/profile.d/conda.csh
modified      /home/hisense/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

[hisense@Master /]$ source ~/.bashrc
(base) [hisense@Master /]$ conda activate hisense

3.激活成功

(hisense) [hisense@Master /]$ 

Linux多用户共用Anaconda环境

上一篇:linux 彻底删除文件及 find命令问题解决


下一篇:从0用eclipse创建工程,run,debug,快捷键