Skip to content

Instantly share code, notes, and snippets.

@knkillname
Created April 23, 2020 23:53
Show Gist options
  • Save knkillname/80999eacfbbf648c68ad4460d63d4f26 to your computer and use it in GitHub Desktop.
Save knkillname/80999eacfbbf648c68ad4460d63d4f26 to your computer and use it in GitHub Desktop.
Install latest Anaconda3 for Ubuntu
wget -O anaconda_installer.sh $(python3 latest_anaconda.py)
bash anaconda_installer.sh -b -u -f -p $HOME/anaconda3
source $HOME/anaconda3/etc/profile.d/conda.sh
conda init
conda config --set auto_activate_base false
#!bin/python3
import datetime
import xml.etree.ElementTree as ET
import operator
import sys
import urllib.request
url = 'https://repo.anaconda.com/archive/'
def get_anaconda_archive():
with urllib.request.urlopen(url) as response:
html = response.read()
document = ET.fromstring(html)
table = document.find('body/table')
rows = iter(table)
header = [td.text for td in next(rows)]
assert header == ['Filename', 'Size', 'Last Modified', 'MD5']
for row in rows:
assert len(row) == len(header)
record = dict(zip(header, (td.text for td in row)))
assert record['Filename'] is None
assert len(row[0]) == 1 and row[0][0].tag == 'a'
record['Filename'] = row[0][0].text
record['Last Modified'] = datetime.datetime.fromisoformat(
record['Last Modified'])
yield record
anaconda_versions = list(get_anaconda_archive())
linux_records = [record
for record in anaconda_versions
if record['Filename'].startswith('Anaconda3')
and record['Filename'].endswith('Linux-x86_64.sh')]
most_recent = max(linux_records, key=operator.itemgetter('Last Modified'))
target = url + most_recent['Filename']
print(target, end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment