I wrote a bash script that has to compare two version strings to decide to download new version or not.The test relies on a Python script that does apt.VersionCompare(), which does version comparison the way apt does.#!/usr/bin/env pythonimport sys, aptres = apt.VersionCompare(sys.argv[1], sys.argv[2])if res < 0:   sys.exit(-1)if res > 0:   sys.exit(1)sys.exit(0)With upgrade to Ubuntu 14.4 this stopped working. I tried to change the script following https://stackoverflow.com/questions/4957514/ as below:#!/usr/bin/env pythonimport sys, apt_pkgres = apt_pkg.version_compare(sys.argv[1], sys.argv[2])if res < 0:   sys.exit(-1)if res > 0:   sys.exit(1)sys.exit(0)but this gives me  ValueError: _system not initialized. How to solve, or is there a better way to compare versions like apt does?
ValueError: _system not initialized when using apt.VersionCompare
apt;python
Strangely the code works when I run it from an interactive Python prompt. At any rate, this bug report points to a solution(?)1: Add a call to apt_pkg.init_system() as documented here (or do import apt as well):#!/usr/bin/env pythonimport sys, apt_pkgapt_pkg.init_system()res = apt_pkg.version_compare(sys.argv[1], sys.argv[2])if res < 0:    sys.exit(-1)if res > 0:    sys.exit(1)sys.exit(0)1Apparently the InitSystem function name has changed too, from CamelCase to using underscores.