How to install Anaconda on Ubuntu?

455,144

Solution 1

See Anaconda Hompepage for more detail!

Installation Instructions [Linux Install]

These instructions explain how to install Anaconda on a Linux system.

After downloading the Anaconda installer, run the following command from a terminal:

$ bash Anaconda-2.x.x-Linux-x86[_64].sh

After accepting the license terms, you will be asked to specify the install location (which defaults to ~/anaconda).

Note: You do NOT need root privileges to install Anaconda, if you select a user writable install location, such as ~/anaconda.* After the self extraction is finished, you should add the anaconda binary directory to your PATH environment variable.

As all of Anaconda is contained in a single directory, uninstalling Anaconda is easy (you simply remove the entire install location directory).


If you encounter any issues, please try disabling your antivirus software. Linux/OS X Uninstall

As all of Anaconda is contained in a single directory, uninstalling Anaconda is simple (you simply remove the entire install location directory):

$ rm -rf ~/anaconda

Solution 2

You can use wget to download from commandline:

For Python3:

  • 32 bits version:

    wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86.sh
    
  • 64 bits version

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

And after download is finished do:

  • 32 bits:

    bash Anaconda3-2020.02-Linux-x86.sh
    
  • 64 bits:

    bash Anaconda3-2020.02-Linux-x86_64.sh
    

For users using Python2, the "3" directly after Anaconda should be changed to a 2.

Source: https://conda.io/docs/user-guide/install/linux.html

Solution 3

Nobody has explained here why apt-get and other package managers don't have packages for anaconda.

An important reason for this is that anaconda is meant to be usable by a user who, for whatever reason, doesn't have root privileges. In that case the user just installs into ~/anaconda, changes her own PATH and PYTHONHOME variables so as to run ~/anaconda/python, and is capable of controlling her personal python distribution, while modifying the "system" python might require an administrator's help.

Package managers always require sysadmin privileges.

Solution 4

If you are trying to it entirely in command line you use a bash script python 2 anaconda install bash script:

# Go to home directory
cd ~

# You can change what anaconda version you want at 
# https://repo.continuum.io/archive/
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
bash Anaconda2-4.2.0-Linux-x86_64.sh -b -p ~/anaconda
rm Anaconda2-4.2.0-Linux-x86_64.sh
echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bashrc 

# Reload default profile
source ~/.bashrc

conda update conda

python 3 anaconda install bash script

# Go to home directory
cd ~

# You can change what anaconda version you want at 
# https://repo.continuum.io/archive/
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
bash Anaconda3-4.2.0-Linux-x86_64.sh -b -p ~/anaconda
rm Anaconda3-4.2.0-Linux-x86_64.sh
echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bashrc 

# Reload default profile
source ~/.bashrc

conda update conda

Source: https://medium.com/@GalarnykMichael/install-python-on-ubuntu-anaconda-65623042cb5a

Solution 5

In addition to @Vivek's answer, to get the latest python3 64-bit Linux version:

CONTREPO=https://repo.continuum.io/archive/
# Stepwise filtering of the html at $CONTREPO
# Get the topmost line that matches our requirements, extract the file name.
ANACONDAURL=$(wget -q -O - $CONTREPO index.html | grep "Anaconda3-" | grep "Linux" | grep "86_64" | head -n 1 | cut -d \" -f 2)
wget -O ~/Downloads/anaconda.sh $CONTREPO$ANACONDAURL
bash ~/Downloads/anaconda.sh -b -p $HOME/anaconda3

The grep filters in line 3 can be altered to match your requirements, of course.

Q: What is going on here?

  • wget -q -O - URL quietly (-q) gets the html at URL (in this case https://repo.continuum.io/archive/, which is accessed as $CONTREPO) and sends it to standard out (-O -).
  • | is called "pipe", and sends the output of the preceding command to the next command.
  • grep "text" returns the lines from its input that contain text. So first, we select all lines that contain "Anaconda3", then of those, we select all lines containing "Linux", and then all lines containing "86_64" (for the 64-bit version).
  • head -n 1 returns the first line of the input. I rely on the website maintaining order so that the most recent version is on top.
  • cut -d \" -f 2 splits the input on the double quote characters (-d \"), which surround the filename in the HTML's href, and returns the second field (-f 2), being the target of the href.
  • -b -p path options make the installation non-interactive "silent-mode", where you silently accept the license and are not asked for confirmation for the installation path.
Share:
455,144
alvas
Author by

alvas

食飽未?

Updated on September 18, 2022

Comments

  • alvas
    alvas over 1 year

    How to install Anaconda for Python on Ubuntu?

    Is there a way to use apt-get install?

    I only have command line access to my server. How do I install Anaconda on Ubuntu 14.04 from the command line?

    • Admin
      Admin over 7 years
      I'm sorry but I just have to ask does your system have the package buns installed? I've heard Anaconda only works with that installed.
    • Admin
      Admin over 7 years
      it would be ideal if there was an answer entirely in the command line. Specially, it seems that the current answers do not tell us how to download the most recent installer for Anaconda. i.e. the wget seem short lived.
    • Admin
      Admin almost 2 years
      I think this works: you can install everything on terminal like this askubuntu.com/a/1412558/230288
  • alvas
    alvas almost 10 years
    how do i update anaconda?
  • Vivek
    Vivek almost 10 years
    $ conda update conda, $ conda update anaconda. Check docs.continuum.io/anaconda/install.html
  • drevicko
    drevicko over 8 years
    how would you recommend installing systemwide?
  • Ciprian Tomoiagă
    Ciprian Tomoiagă over 7 years
    @nealmcb on my SSD it took less than 10 minutes
  • Charlie Parker
    Charlie Parker over 7 years
    how do you do the first step in the terminal without a web browser? I am trying to run this in a docker container so I need the command.
  • Charlie Parker
    Charlie Parker over 7 years
    from your wget commands, it seems that its not possible to install anaconda through apt-get or some more "official" ubuntu package manager? Is that right?
  • v2r
    v2r over 7 years
    @Charlie Parker: I am sorry, but I don't have an answer to this questions.
  • Charlie Parker
    Charlie Parker over 7 years
    So you don't know how to do the "After downloading the Anaconda installer" in the command line? (I am quoting your answer)
  • Charlie Parker
    Charlie Parker over 7 years
    it seems that the current answer do not tell us how to download the most recent installer for Anaconda. i.e. the wget seem short lived. Do you know how to d that part?
  • Charlie Parker
    Charlie Parker over 7 years
    @Vivek can you clarify what your conda update thing is?
  • k_g
    k_g about 7 years
    This installs anaconda for python2, not python3. (Just a clarification to future readers).
  • landroni
    landroni about 7 years
    Be careful as Anaconda seems to install their own version of moc (for building Qt apps), which may conflict with the system libraries if you compile when /home/USER/anaconda3/bin is in your path.
  • Monica Heddneck
    Monica Heddneck about 6 years
    This actually answers the question and should be the accepted answer
  • information_interchange
    information_interchange almost 6 years
    @CharlieParker Check this guide, essentially you can just curl the file and save the response: digitalocean.com/community/tutorials/…
  • Donot Don't
    Donot Don't about 5 years
    i try to use export PATH="~/anaconda3/bin:$PATH" work for me.
  • Shlomo
    Shlomo about 5 years
    You can see the list of versions available here: repo.anaconda.com/archive.
  • skan
    skan about 5 years
    Is it better to install it as root or not?
  • Robert
    Robert over 4 years
    Package managers don't always need root access; Maven, Gradle, cpan, and NPM do fine without. Even then you could put the package manager itself in the Ubuntu repository and have it install packages on a per-user or even per-project basis.
  • Galigator
    Galigator almost 4 years
    When requiere project that have a "pricing" don't use standarized package management it always yield a warning for me. Then I deploy it in a docker environnement... not that a big deal for an environnement manager.
  • Admin
    Admin almost 2 years
    you can install everything on therminal like this askubuntu.com/a/1412558/230288
  • Admin
    Admin almost 2 years
    you can install everything on therminal like this askubuntu.com/a/1412558/230288
  • Admin
    Admin almost 2 years
    I think my answer is similarly good to yours you can install everything on therminal like this askubuntu.com/a/1412558/230288 I am curious how you skipped the activate conda step I did
  • Admin
    Admin almost 2 years
    you can install everything on therminal like this askubuntu.com/a/1412558/230288 which is similar to yours.