Accommodating the changeover to Python 3.

Created by Favux
Keywords:
Python 3 python python2
Last updated by:
Favux

Magick Rotation requires Python 2 to run. Some of the Distros are now switching to Python 3 with their new releases. Amongst them are Arch Linux. Fedora, and Ubuntu (Quantal Quetzal or 12.10).

To determine your Distro's default version of Python enter into a terminal the following command:
    python -V

Python 2 can coexist with Python 3 without a problem. If your Distro has switched to Python 3 you may need to install Python 2 from the Distro's official repositories.

The 'python' symlink is used by Distros to point to their default version of Python. To accommodate the changeover the Magick Rotation 1.6.2 shebang lines, at the beginning of the modules, have been changed from either:
#!/usr/bin/env python
  or
#!/usr/bin/python

to:
#!/usr/bin/env python2
  or
#!/usr/bin/python2

This specifies that Magick Rotation uses Python 2.

This will work provided the Distro has included a symlink pointing 'python2' to its version of Python 2 (usually Python 2.7.x). Most Distros have included this symlink whether or not they're using Python 2 or 3 as the default. Which means this alteration to Magick should also be backwards compatible.

Unfortunately this is not true of some, such as Linux Mint and LMDE (Linux Mint Debian Edition). Since LMDE is based on Debian, Debian may also lack the 'python2' symlink. This is easily remedied by creating the symlink yourself.

CREATING A PYTHON2 SYMLINK
If your Distro does not have the 'python2' symlink when you run the following terminal commands:
    ./MAGICK-INSTALL
or
    ./magick-rotation
you should see this error.
"bash: ./MAGICK-INSTALL: /usr/bin/python2: bad interpreter: No such file or directory"

To check for the 'python2' symlink execute the following command:
    ls -l /usr/bin/python*

Using LMDE as an example the output is:
lrwxrwxrwx 1 root root 9 Jun 5 22:08 /usr/bin/python -> python2.7
-rwxr-xr-x 1 root root 2663928 Jun 25 15:58 /usr/bin/python2.6
-rwxr-xr-x 1 root root 3001712 Apr 22 18:17 /usr/bin/python2.7
lrwxrwxrwx 1 root root 9 Jul 12 23:51 /usr/bin/python3 -> python3.2
lrwxrwxrwx 1 root root 11 Jun 25 18:12 /usr/bin/python3.2 -> python3.2mu
-rwxr-xr-x 1 root root 2892712 Jun 25 18:12 /usr/bin/python3.2mu
lrwxrwxrwx 1 root root 11 Jul 12 23:51 /usr/bin/python3mu -> python3.2mu

There is no 'python2' and 'python' points to 'python2.7'. Double checking the Python version in LMDE with 'python -V' shows "Python 2.7.3rc2". So we now know to point our symlink to 'python2.7'.

Enter the following command as root in a terminal to create the missing 'python2' symlink, e.g.:

    sudo ln -s /usr/bin/python2.7 /usr/bin/python2

The link (ln) command uses the -s switch to create a symbolic link with python2.7 as the target and python2 as the link name.

Now repeating the 'ls -l /usr/bin/python*' command you can see the 'python2' symlink has been created.
lrwxrwxrwx 1 root root 9 Jun 5 22:08 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root 18 Oct 1 14:35 /usr/bin/python2 -> /usr/bin/python2.7
-rwxr-xr-x 1 root root 2663928 Jun 25 15:58 /usr/bin/python2.6
-rwxr-xr-x 1 root root 3001712 Apr 22 18:17 /usr/bin/python2.7
lrwxrwxrwx 1 root root 9 Jul 12 23:51 /usr/bin/python3 -> python3.2
lrwxrwxrwx 1 root root 11 Jun 25 18:12 /usr/bin/python3.2 -> python3.2mu
-rwxr-xr-x 1 root root 2892712 Jun 25 18:12 /usr/bin/python3.2mu
lrwxrwxrwx 1 root root 11 Jul 12 23:51 /usr/bin/python3mu -> python3.2mu

Magick Rotation 1.6.2 and its INSTALLER should now work.