Installing wxPython on Ubuntu 12.04

40,004

Solution 1

Okay, so I was able to figure it out. It turned out to be a combination of things.

  1. First make sure that you have Python installed
  2. Install wxGTK 2.8 with the command, sudo apt-get install python-wxgtk2.8
  3. Run the command, apt-get source -d wxwidgets2.8
  4. Now run, dpkg-source -x wxwidgets2.8_2.8.12.1-6ubuntu2.dsc
  5. cd wxwidgets2.8-2.8.12.1
  6. cd wxPython
  7. Now run the command, sudo python setup.py install
  8. wxPython and wxWidgets are now successfully installed!

Solution 2

Okay. So I have figured out a way out Just run the following command in a Terminal:

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-doc wx2.8-examples wx2.8-headers wx2.8-i18n

And Voila! It works!

Solution 3

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n libwxgtk2.8-dev libgtk2.0-dev Works for me

source:http://wiki.wxpython.org/InstallingOnUbuntuOrDebian

Solution 4

You can also install it with Pip, but with a slight modification to the install command.

From the wxPython website:

Because of the differences between Linux distributions (mainly different versions of the core libraries installed by default, but also platform architecture and etc.) it is not possible to host binary wheel files for Linux on PyPI unless they can be made to work within the constraints of PEP 513 Unfortunately, attempts to pound the wxPython peg into the manylinux1 hole have not been very successful. Maybe manylinux2 will be a better fit. In the meantime, if you have a Linux similar enough to those used to build the wheels located under the wxPython Extras linux folder, then you can use them and not need to build the wheels yourself.

Since there are various options for distro and wx port (GTK2 or GTK3) then the files can not all be located in the same folder for easy access by pip. This simply just means that you'll need to drill down a little further to find the URL to give to pip. For example, to get the GTK3 wxPython builds for Ubuntu 16.04 (and 16.10, LinuxMint 18, and probably others) you can use a pip command like this:

pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython

Solution 5

gtk3 should be install first

$sudo apt-get libgtk-3-dev

If you are facing problem to install wxpython on Python3 please use this command to install wxpython

$ pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython

By this command you can install latest wxPython4 version. If you are using Windows or macOS

$ pip install -U wxpython
Share:
40,004
John Zeller
Author by

John Zeller

Updated on April 18, 2020

Comments

  • John Zeller
    John Zeller about 4 years

    The Issue: I am having trouble installing wxPython on Ubuntu 12.04. I would like to find a simple, straightforward way of doing this.

    What I've Done So Far: The most relevant instructions that I have been able to find so far can be found here: http://wiki.wxpython.org/InstallingOnUbuntuOrDebian

    The issue with these instructions is that there is no choice available for Precise 12.04. The most up-to-date distro shown is Natty 11.4. From what I can find, the proper way to do this is to manually build debian packages, which is explained here: http://wiki.wxpython.org/BuildingDebianPackages

    Upon attempting this and finally typing the command 'fakeroot debian/rules binary', I get the errors:

    debian/rules:14: /usr/share/quilt/quilt.make: No such file or directory
    pyversions: missing X(S)-Python-Version in control file, fall back to debian/pyversions
    pyversions: missing debian/pyversions file, fall back to supported versions
    make: *** No rule to make target `/usr/share/quilt/quilt.make'. Stop.

    I cannot seem to fix this error, or find any other applicable resources that work for me. I would post more links here, but since I am new, the spam filter is blocking me from doing so.

    Conclusion: Does someone know a simple solution to properly installing wxPython on Ubuntu 12.04 Precise?

    Update: I tried just simply using the apt-get command 'sudo apt-get install python-wxgtk2.8', and I received this (which seems good):

    Reading package lists... Done
    Building dependency tree

    Reading state information... Done
    python-wxgtk2.8 is already the newest version.
    The following packages were automatically installed and are no longer required:
    language-pack-zh-hans yaml-cpp language-pack-kde-en language-pack-kde-zh-hans language-pack-kde-en-base language-pack-zh-hans-base language-pack-kde-zh-hans-base
    Use 'apt-get autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 173 not upgraded.

    But once I attempt to run something, ie 'python test_gui.py', I get the following error:

    Traceback (most recent call last):
    File "test_gui.py", line 1, in
    import wx
    ImportError: No module named wx

  • joe_zeroh
    joe_zeroh about 11 years
    the following dependencies are required: dpkg-dev build-essential swig python2.7-dev libwebkitgtk-dev libjpeg-dev libtiff-dev freeglut3 freeglut3-dev libgtk2.0-dev libsdl1.2-dev libgstreamer-plugins-base0.10-dev -- (from: wiki.wxpython.org/CheckInstall)
  • evadeflow
    evadeflow about 11 years
    Awesome, thanks for this! FYI, the last command (for me) emitted an error: In file included from src/helpers.cpp:16:0: include/wx/wxPython/wxPython_int.h:19:19: fatal error: wx/wx.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status 1. But it appears you can safely ignore this. wxPython worked fine for me, despite the 'scary' output at the end...
  • user426364
    user426364 about 10 years
    Easier than the accepted answer, which was giving me: unable to find a source package for wxwidgets2.8
  • Nimajen
    Nimajen almost 10 years
    Works perfectly. Thanks !
  • Mike
    Mike almost 10 years
    Same experience as evadeflow above, but had to restart the terminal/python/etc to have it work.
  • Jonathan Hartley
    Jonathan Hartley almost 10 years
    This didn't work for me: Ubuntu 12.10, Python2.6. $python -c "import wx" Traceback (most recent call last): File "<string>", line 1, in <module>, File "wx/__init__.py", line 45, in <module>, from wx._core import *, File "wx/_core.py", line 4, in <module>, import core, ImportError: No module named core
  • Jonathan Hartley
    Jonathan Hartley almost 10 years
    If you want to install in a virtualenv (and why would you be doing anything else?) then replace step 7 with "python setup.py sdist", and you can install the resulting dist/xxx.tar.gz wherever you like using pip.