Invalid version number error with Python


I tried to import a Python package that I had installed from source. The import failed with this error:

File "/usr/lib/python2.7/distutils/", line 40, in __init__
File "/usr/lib/python2.7/distutils/", line 107, in parse
  raise ValueError, "invalid version number '%s'" % vstring
ValueError: invalid version number '2.7.0rc3'


It turns out that package version number has to be in the x.y.z format. Else Python throws this error.

Since I had the source code of this package, I found all instances of 2.7.0rc3 and changed it to 2.7.0. Typically, this will be in the and files. I removed the previously installed package and reinstalled this changed source code. I was able to import after this successfully.

Tried with: Ubuntu 14.04


How to find version of XFree86

XFree86 is an implementation of the X Window System. You may need to know which version of XFree86 is running on your computer.

Finding this is easy:

$ X -version

For information about other options:

$ X -help

The X man page does not list any of the options and is not useful for this purpose.

Tried with: X 1.17.1 and Ubuntu 14.04

How to switch GCC version using update-alternatives

Multiple versions of GCC can be installed and used on Ubuntu as described here. The update-alternatives tool makes it easy to switch between multiple versions of GCC.

On Ubuntu, gcc and g++ are just symbolic links to the actual binaries of a specific version of GCC. By switching the version, invoking gcc will execute the particular version of the compiler binary that you wish. You can make any of these version as the default at any time effortlessly.

As an example, I had installed GCC version 4.8 from the Ubuntu repositories. This was the default version of GCC, so gcc was a symlink to gcc-4.8 binary. Wanting to use some new C++11 features I installed version 4.9 of GCC. This compiler can be invoked using gcc-4.9. I now want to switch the default gcc to invoke gcc-4.9. I also want the freedom to switch back 4.8 as the default whenever I want. You can switch the symlinks yourself manually, but using this tool makes it easy and clean.

Let us begin:

  • Decide which set of symbolic links you want to group together as one unit. I like to switch /usr/bin/gcc and /usr/bin/g++ together.

  • Pass update-alternatives the first version of these symbolic links. Here I will inform about the 4.8 version of these tools and links:

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

Here, we have provided the gcc as the master and g++ as slave. Multiple slaves can be appended along with master. When master symbolic link is changed, the slaves will be changed too.

  • Pass the second version of these tools to be recorded:
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 
  • Now you can switch between these versions by using:
$ sudo update-alternatives --config gcc

Tried with: Ubuntu 14.04

Unsupported major.minor version error


I executed a Java program downloaded from the web and got this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: net/filebot/Main : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at sun.launcher.LauncherHelper.checkAndLoadMain(


This error from the Java virtual machine (VM) executing the Java class file indicates that the version 52.0 is not supported by it. This is usually means that the Java program requires a newer version of Java VM for its execution.

The mysterious part is the number 52, which is much higher than any Java version we know. This is a Java class file format version number. The Java version that maps to 52 can be found from the table of class file format version to Java version mapping. For 52.0, it is Java 8. So, this error means that I need to have Java 8 VM to execute this class file. That was correct since I had Java 7 on this computer.

Major.Minor version of Java class file

A Java class file holds the Java bytecode for a Java class that can be executed on a Java virtual machine (VM). Encoded at the beginning of a class file is a major and minor version number of the class file format that is used in it. This major.minor number indicates which Java VM can execute this class file. The class file format is typically changed with a new release of Java.

The mapping from Java version to the major number is as follows:

J2SE 8 = 52
J2SE 7 = 51
J2SE 6.0 = 50
J2SE 5.0 = 49
JDK 1.4 = 48
JDK 1.3 = 47
JDK 1.2 = 46
JDK 1.1 = 45

Reference: Wikipedia page on Java class file

Visual Studio versions

Visual Studio has a branded name with a year (like Visual Studio 2013), but also an internal version number. Visual Studio supports a C++ compiler, a C# compiler, the .Net Framework and many other internal tools. Each of these also have their own version names and numbers. Confusingly, either the year-version or version-number is used at several places in Windows.

Here is some information I note down and update as I use these software:

Visual Studio 2015

  • Visual Studio: 14
  • Visual C++ compiler: 19.0.23026.0
  • Visual C compiler: 19.0.23026.0

Visual Studio Professional 2013

  • Visual Studio: 12.0
  • Visual C++ compiler: 18.0.21005.1
  • Visual C compiler: 18.0.21005.1
  • Microsoft .Net Framework: 4.5.50938

Visual Studio Professional 2012

  • Visual Studio: 11.0
  • Visual C++ compiler: 17.00.50727.1
  • Visual C compiler: 17.00.50727.1

How to find version of OpenCV

To print the version of OpenCV that you are using:

#include <opencv2/opencv.hpp>

std::cout << CV_VERSION << std::endl;

CV_VERSION is a macro that is defined in modules/core/include/opencv2/core/version.hpp as seen here. It combines the values of five definitions provided in the same file:

#define CV_VERSION_EPOCH    3
#define CV_VERSION_MAJOR    0
#define CV_VERSION_MINOR    0
#define CV_VERSION_STATUS   "-dev"

How to find the version of your PowerShell

How do you find out the version of PowerShell you are using? This information can be found from the PSVersionTable variable. It holds the versions of the various components of PowerShell.

$ $PSVersionTable
Name                           Value
----                           -----
CLRVersion                     2.0.50727.5448
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
PSRemotingProtocolVersion      2.1

To find just the version of the shell component:

$ $PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

So, I am using version 2.0 🙂

Tried with: PowerShell 2.0