Check out the latest superpixel benchmark — Superpixel Benchmark (2016) — and let me know your opinion! @david_stutz

SERIES»Working with Ubuntu«

Low Graphics Mode, Stuck on Shutdown and OpenCV Autocompletion in Spyder

This series collects tips and tricks for working with Ubuntu. The first article in the series starts with low graphics mode, stuck on shutdown and OpenCV autocompletion in Spyder.

Ubuntu is a wonderful distribution. Personally, I started using it on an every-day basis for programming. However, in my opinion, Ubuntu has a steeper learning curve than Windows - often I stumbled across problems requiring me to blindly execute unknown commands taken from Google. Nevertheless, I slowly grew accustomed to the Linux/Ubuntu-style of working. In this series, "Working with Ubuntu" I want to share some of the problems I stumble upon in future.

There are some good tips on enabling low graphics mode (e.g. for an old laptop, or before (re-)installing graphic drivers):

I followed the former one by installing compizconfig-settings-manager. However, note not to disable unity by mistake! - Otherwise go with the following links on how to enable Unity again: How to enable Unity again?, Enabling window decorations made me disable Unity.

If Ubuntu is stuck on shutdown (i.e. if the shutdown indicator below the Ubuntu logo is stuck), both answers of this post might help: Ubuntu 14.04 stuck on shutdown. For me, a combination of the following two approaches did the trick:

  1. changing/etc/default/grub



    GRUB_CMDLINE_LINUX_DEFAULT="acpi=noirq acpi=force apm=power_off quiet splash"

    in /etc/default/grub (use sudo gedit /etc/default/grub) and then updating GRUB: sudo update-grub.

  2. In /etc/modules add

    apm power_off=1

    below the line saying lp and again update GRUB: sudo update-grub.

Spyder is a popular Python IDE, offering intuitive autocompletion for most frequently used packages including NumPy. Unfortunately, Spyder does not necessarily provide autocompletion for OpenCV - or autocompletion is not configured correctly. This issue is discussed in more detail here:spyder-ide/Issue #1469. On Ubuntu, the following solution worked (tested with Ubuntu 14.04): In spyderlib/utils/module_completion.py (which may be found in /usr/lib/python2.7/dist-packages/spyderlib/utils) search for the following part of code:

def get_preferred_submodules():
    Get all submodules of the main scientific modules and others of our
    if modules_db.has_key('submodules'):
        return modules_db['submodules']
    mods = ['numpy', 'scipy', 'sympy', 'pandas', 'networkx', 'statsmodels',
            'matplotlib', 'sklearn', 'skimage', 'mpmath', 'os', 'PIL',
            'OpenGL', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO',
            'cmath', 'collections', 'datetime', 'errno', 'exceptions', 'gc',
            'imageop', 'imp', 'itertools', 'marshal', 'math', 'mmap', 'msvcrt',
            'nt', 'operator', 'parser', 'rgbimg', 'signal', 'strop', 'sys',
            'thread', 'time', 'wx', 'xxsubtype', 'zipimport', 'zlib', 'nose',
            'PyQt4', 'PySide', 'os.path', 'cv2'] # add 'cv2' here!

    submodules = []
    for m in mods:
        submods = get_submodules(m)
        submodules += submods
    modules_db['submodules'] = submodules
    return submodules

which started around line 266; add 'cv2' to the array of supported packages.

More from »Working with Ubuntu«:

What is your opinion on this article? Did you find it interesting or useful? Let me know your thoughts in the comments below or get in touch with me: