most of time we may meet some installation and lib dependency problems. For the latest Ubuntu version, the problems still happen. Below are some common problems which happened frequently and their solution:
---------------------------------------------------------------------------------------------------------------
Problem [1]: Install wxPython on Ubuntu 20.04 fail because of dependency package Gtk is not installed.
Error Message:
No package 'gtk+-3.0' found
Package gthread-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gthread-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gthread-2.0' found
no
*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occurred. This usually means GTK+ is incorrectly installed.
OS Platform : Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04.
Type: Dependency package not installed.
Solution:
- Solution[1]: Install wxPython package with Gtk package bind in:
sudo apt install libgtk-3-dev sudo apt-get install python-wxgtk3.0​
- Solution [2] : If solution[1] shows install error for latest Ubuntu version(20.04), install the related dependency package:
sudo apt-get install python3-wxgtk4.0 python3-wxgtk-webview4.0 python3-wxgtk-media4.0​
- Solution[3] : After finished the step in solution[2] and also try pip-installation "pip install wxPython". If the pip-installation still not work, install the specific wxPython package(it is compatible for 20.04 ):
sudo pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython​
---------------------------------------------------------------------------------------------------------------
Problem [2]: Successfully installed wxPython package but got error during import it in program.
Error Message:
python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/wx/__init__.py", line 17, in
from wx.core import *
File "/usr/local/lib/python3.8/dist-packages/wx/core.py", line 12, in
from ._core import *
ImportError: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
OS Platform : Ubuntu 20.04.
Type: wxPython_v4.x related lib SDL2-X packages are not installed.
Solution:
sudo apt-get install git curl libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-2.0-0
---------------------------------------------------------------------------------------------------------------
Problem [3]: Successfully installed wxPython package but got error during import it in program.
Error Message:
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/wx/__init__.py", line 17, in
from wx.core import *
File "/usr/local/lib/python3.8/dist-packages/wx/core.py", line 12, in
from ._core import *
ImportError: libpng12.so.0: cannot open shared object file: No such file or directory
OS Platform : Ubuntu 20.04.
Type: wxPython_v4.x related lib png12/14 packages are not installed.
Solution:
Download the lib deb "libpng12-0_1.2.54-1ubuntu1b_amd64.deb" from below link :
https://www.dropbox.com/s/79x3imq73tcqyw4/libpng12-0_1.2.54-1ubuntu1b_amd64.deb?dl=0 or https://github.com/LiuYuancheng/Power_Generator_Manager/blob/master/lib/libpng12-0_1.2.54-1ubuntu1b_amd64.deb
Install the lib by cmd:
sudo dpkg -i libpng12-0_1.2.54-1ubuntu1b_amd64.deb
Note: This post is authorized to republish here by Yuancheng Liu, Systems Software Engineer at ZycraftUSV.PTE.LTD. Original post is here.
tx, your solution for problem 2 fixed mine :p