简体   繁体   中英

How can I install the latest Anaconda with wget

I'm looking at installing anaconda via wget on my server. I've come across https://askubuntu.com/questions/505919/installing-anaconda-python-on-ubuntu and http://ericjonas.com/anaconda.html and it looks promising. As of this writing the current version( https://www.continuum.io/downloads#_unix ) is 4.0. How can I wget the latest version.

wget just downloads the file...

for python 2.7 :

wget https://repo.continuum.io/archive/Anaconda2-2018.12-Linux-x86_64.sh

for python3.X:

wget https://repo.continuum.io/archive/Anaconda3-2018.12-Linux-x86_64.sh

This is a shell script that guides you though the install.

Run the following line inside of the folder of the downloaded file to start the guided install...

for python 2.7:

bash Anaconda2-2018.12-Linux-x86_64.sh

for Python 3.X:

bash Anaconda3-2018.12-Linux-x86_64.sh

Check latest repos or if you want any specific version here: https://repo.continuum.io/archive/

这将从网站上抓取 html 下载最新的 anaconda 版本:

wget -O - https://www.anaconda.com/distribution/ 2>/dev/null | sed -ne 's@.*\(https:\/\/repo\.anaconda\.com\/archive\/Anaconda3-.*-Linux-x86_64\.sh\)\">64-Bit (x86) Installer.*@\1@p' | xargs wget

This gets you the latest miniconda 3 for 64bit Linux environments:

  1. download the software with wget
  2. assign execution rights
  3. execute and follow the instructions
  4. load .bashrc to update PATH environment variable
  5. update conda
  6. install pip
  7. create an enviroment

...

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc

# now update conda and install pip
conda update conda
conda install pip

# (optional) create and activate an environment
conda create -n py3 python pandas scikit-learn jupyter
source activate py3

You can write the following bash script to automate the installing process.

cd ~

wget https://repo.continuum.io/archive/Anaconda3-2020.11-Linux-x86_64.sh
bash Anaconda3-2020.11-Linux-x86_64.sh -b -p ~/anaconda3
rm Anaconda3-2020.11-Linux-x86_64.sh
echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc 

# Reload default profile
conda init

source ~/.bashrc

I would just go to https://repo.anaconda.com/archive/ and copy the link of the most recent dated release and use wget with that. For example, right now it would be:

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

If you want a more automatic way you could try the following.

Using @philipper solution as a starting point I made some modifications.

  latest=$(wget -qO- https://repo.anaconda.com/archive/  | 
  grep -Eo "(href=\")(Anaconda3-.*-Linux-x86_64.sh)*\"" | 
  sed 's/href=//g' | sed 's/\"//g' | head -n 1); wget "https://repo.anaconda.com/archive/$latest"

The script will download the html of the repo archive page. Parse out all href tags matching Anaconda3 for Linux-x86 _64 (1st sed).

I strip out the "href=" and quotes from that output (2nd & 3rd sed).

I then get the first entry which will be the most recent and set it to the variable latest. Then use wget to download from the full url.

Either way, once it's downloaded you'll most likely need to make the.sh file executable then you can just run it like a normal.sh file.

I would just do it the first way but the second way does work for now at least.

I'm not really good at bash or using sed so my "automatic" solution might have some issues.

How to install latest Anaconda (2022)

$ ANACONDA_VERSION=$(curl -sS https://repo.anaconda.com/archive/ | grep -Po '(?<=Anaconda3-)([0-9.]*)(?=-Linux-x86_64)' | head -n1)
$ ANACONDA_URL="https://repo.anaconda.com/archive/Anaconda3-${ANACONDA_VERSION}-Linux-x86_64.sh"
$ wget $ANACONDA_URL && bash $(basename $ANACONDA_URL) -b
  • https://repo.anaconda.com/archive/ lists the release anaconda installer binaries, in the order of latest released.
  • The grep command grep -Po '(?<=Anaconda3-)([0-9\\.]*)(?=-Linux-x86_64)' extracts the \d\d\d\d.\d\d string, where Anaconda3- and -Linux-x86_64 are lookahead patterns. grep -Po is a useful, clean command to extract some regex pattern from a string (one could do with sed as well).
  • | head -n1 | head -n1 : choose whichever comes the first, ie the latest release.

Miniforge / Miniconda (automatic latest):

$ MINIFORGE_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh"
$ wget $MINIFORGE_URL && bash $(basename $MINIFORGE_URL) -b
$ MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
$ wget $MINICONDA_URL && bash $(basename $MINICONDA_URL) -b

Remarks

Note: the -b option is for the "batch mode" -- no question asked, accept the license, etc. and just install the anaconda for you. One may also find the option -p $CONDA_PREFIX useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM