How to install Anaconda python for all users?

PythonAnaconda

Python Problem Overview


Anaconda python distribution is very convenient to deploy scientific computing env (SCE) and switch python versions as you want. By default, the installation will locate python into ~/anaconda and the SCE can only benefit the local user.

But what I need is to provide a complete SCE wit Anaconda while masking the system-wide python version, because my cluster is running Spark and provides services for multiple users in our team. Is it possible with current Anaconda version?

Xiaming

Python Solutions


Solution 1 - Python

The installer lets you install anywhere. You can install it to a global location, like /opt/anaconda.

Solution 2 - Python

Add the anaconda PATH to /etc/profile:

for anaconda 2 :

PATH=$PATH:$HOME/anaconda/bin

for anaconda 3 :

PATH=$PATH:$HOME/anaconda3/bin

and then :

source /etc/profile

Solution 3 - Python

Anaconda Cluster from Continuum that addresses these issues. Check out https://docs.continuum.io/anaconda-scale/

Solution 4 - Python

You definitely need to install to a path which is accessible from all users. /opt/YOUR_CONDA_DISTRIB_NAME is a good candidate.

However you also have to add conda path which automatically happens when you add the following shell script to other users' .bashrc files. You can find the shell script in the root user's .bashrc file. For the record, I bring it here:


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/YOUR_CONDA_DISTRIB_NAME/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/YOUR_CONDA_DISTRIB_NAME/etc/profile.d/conda.sh" ]; then
        . "/opt/YOUR_CONDA_DISTRIB_NAME/etc/profile.d/conda.sh"
    else
        export PATH="/opt/YOUR_CONDA_DISTRIB_NAME/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<


P.S. a few common names which Anaconda commonly uses for YOUR_CONDA_DISTRIB_NAME:

  • anaconda
  • anaconda3
  • miniconda
  • miniconda3

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncaesar0301View Question on Stackoverflow
Solution 1 - PythonasmeurerView Answer on Stackoverflow
Solution 2 - PythonHISIView Answer on Stackoverflow
Solution 3 - PythonBack2BasicsView Answer on Stackoverflow
Solution 4 - PythonShayan AmaniView Answer on Stackoverflow