'How to install wxPython 2.8 on Ubuntu 18.04?

I am trying to install wxPython 2.8 on Ubuntu 18.04 system. But it is failing with below error :

$ sudo apt install python-wxgtk2.8
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python-wxgtk2.8 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-wxgtk2.8' has no installation candidate

Let me know how to resolve above error so that I can install wxPython 2.8



Solution 1:[1]

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 18.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

Of course you can always download the wheel file yourself and then use pip to install your local copy of the file.

Solution 2:[2]

From https://extras.wxpython.org/wxPython4/extras/

Just open your terminal and do :

URL=https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04

pip install -U -f $URL wxPython

This worked for me !

Solution 3:[3]

This might help you out:

sudo echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" | sudo tee /etc/apt/sources.list.d/wily-copies.list
sudo apt-get update
sudo apt-get install python-wxgtk2.8

Solution 4:[4]

I used this in an xterminal to include trusty repository in synaptic.

echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" | sudo tee /etc/apt/sources.list.d/wily-copies.list

after this in Synaptic-packagemanager reloaded the repository and then I installed it. Be sure to un-select the repository (under "Settings" "Repositories" "Additional repositories") so you won't install obsolete software from this old repository

Solution 5:[5]

After waiting long enough the process was complete and I got wxPython 4 installed.

run

sudo apt install make gcc libgtk-3-dev libwebkitgtk-dev libwebkitgtk-3.0-dev libgstreamer-gl1.0-0 freeglut3 freeglut3-dev python-gst-1.0 python3-gst-1.0 libglib2.0-dev ubuntu-restricted-extras libgstreamer-plugins-base1.0-dev
  • sudo pip install wxpython
  • wait for a while for it to install

after completion, you will see this message.

The directory '/home/user-ii-6/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory '/home/user-ii-6/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting wxpython
  Downloading https://files.pythonhosted.org/packages/dd/31/bd55ab40e406a026a7fda0bb5eb61f466682544ae91ac26267c750f5e618/wxPython-4.0.3.tar.gz (68.5MB)
    100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 68.5MB 929kB/s 
Requirement already satisfied: six in ./.local/lib/python2.7/site-packages (from wxpython) (1.11.0)
Requirement already satisfied: PyPubSub in ./.local/lib/python2.7/site-packages (from wxpython) (4.0.0)
Requirement already satisfied: typing in ./.local/lib/python2.7/site-packages (from PyPubSub->wxpython) (3.6.6)
Installing collected packages: wxpython
  Running setup.py install for wxpython ... done
Successfully installed wxpython-4.0.3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nitai Bhattacharyya
Solution 2 Thoutmos Sanebankh
Solution 3 Ramsharan
Solution 4 Nic3500
Solution 5