I am running Linux Ubuntu 14.04 LTS and am trying to install wxPython so I can develop GUIs on python.

I have python 2.7 and 3 installed but 2.7 in default.

I have installed wxPython as recommended on their website by doing:

apt-get install python-wxgtk2.8

It said that it had installed ok, but when I go into python, both 2.7 and 3.0, and I import the library (import wx) I get the error:

>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named wx

Results from running apt-cache policy python-wxgtk2.8 and dpkg -l python-wxgtk2.8

kiancross@whb:/etc/apt$ apt-cache policy python-wxgtk2.8
  Version table:
 *** 0
        500 http://gb.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status
kiancross@whb:/etc/apt$ also dpkg -l python-wxgtk2.8

kiancross@whb:/etc/apt$ dpkg -l python-wxgtk2.8
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                   Version          Architecture     Description
ii  python-wxgtk2.8 amd64            wxWidgets Cross-platform C++ GUI toolkit (wxPython

I checked /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py. I have the file there as you can see below. You can see what I was returned with when I ran dpkg -S /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py

kiancross@whb:/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx$ ls -a
.            calendar.py    _core.py    glcanvas.py   __init__.py   py              __version__.pyc  _wizard.so
..           calendar.pyc   _core.pyc   glcanvas.pyc  __init__.pyc  richtext.py     webkit.py        xrc.py
animate.py   _calendar.so   _core_.so   _glcanvas.so  lib           richtext.pyc    webkit.pyc       xrc.pyc
animate.pyc  combo.py       _gdi.py     grid.py       media.py      _richtext.so    _webkit.so       _xrc.so
_animate.so  combo.pyc      _gdi.pyc    grid.pyc      media.pyc     stc.py          _windows.py
aui.py       _combo.so      _gdi_.so    _grid.so      _media.so     stc.pyc         _windows.pyc
aui.pyc      _controls.py   gizmos.py   html.py       _misc.py      _stc.so         _windows_.so
_aui.so      _controls.pyc  gizmos.pyc  html.pyc      _misc.pyc     tools           wizard.py
build        _controls_.so  _gizmos.so  _html.so      _misc_.so     __version__.py  wizard.pyc
kiancross@whb:/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx$ dpkg -S /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py
python-wxgtk2.8: /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py

kiancross@whb:~$ ipython
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
Type "copyright", "credits" or "license" for more information.

IPython 1.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import wx

In [2]: wx.__file__
Out[2]: '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.pyc'

Does anyone know why it doesn't work?

  • apt-cache policy python-wxgtk2.8, also dpkg -l python-wxgtk2.8, please. Paste into question, not as a comment. Feb 8, 2015 at 13:26
  • @FaheemMitha I have pasted the results of this into the question. Thank you.
    – user100599
    Feb 8, 2015 at 13:32
  • Python 2.7 and Python 3.4 are both part of the default Ubuntu installation. You didn't install them again from source, did you?
    – muru
    Feb 8, 2015 at 13:35
  • @muru I installed idle from the software manager. Unless this also installs python from source, then no I didn't.
    – user100599
    Feb 8, 2015 at 13:36
  • 1
    Check if you have /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py. Also check dpkg -S /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py. Feb 8, 2015 at 13:39

2 Answers 2


After a conversation with the poster in chat (starting at http://chat.stackexchange.com/transcript/message/19959589#19959589) it became clear he had two versions of Python 2.7 installed. One of them, 2.7.6, was the system (Ubuntu binary package) version, the other (2.7.5) was a local installation, in /usr/local.

His python was picking up the 2.7.5,while ipython and Idle were picking up 2.7.6. Since the wxpython package was installed from a binary package. the python interpreter could not see it. It is unclear why ipython saw one, and python saw the other. Maybe python was a local install too.

The poster is not sure what to do at this point, and it is difficult to advise him. The natural thing to do would be to remove the local installation, but that would require knowing how the installation was done in the first place, what packages were installed, and if he has anything important depending on it.

  • I have updated my answer with what happens when I check to see what python is importing. I'm not too sure what to mean when you say to check which package it belongs to.
    – user100599
    Feb 8, 2015 at 13:49

There are three possible reasons:

  1. The package in Ubuntu is broken or unconfigured. First is unlikely, it would be a bug report somewhere, and second is false since dpkg reports ii for installed packages.
  2. You are using an interactive python shell that was opened before you installed the module. This is the most likely reason. Just close the shell and open it again, it should work.
  3. You are not using your system python binary, this includes pip, virtualenv, or manual installations from source.
  • Ok, this has sort of fixed my problem :) So when I use idle, it works fine, but if I run my script in terminal or I run python in the terminal I get the error when running import wx.
    – user100599
    Feb 8, 2015 at 14:06

You must log in to answer this question.