Python Forum
[WxPython] Linux: No module named 'wx'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] Linux: No module named 'wx'
#1
When I run my little Python script in the shell, I get the following error:

Error:
Traceback (most recent call last): File "./learn.py", line 6, in <module> import wx ModuleNotFoundError: No module named 'wx'
I use:
Xubuntu Linux 18.04
Python 3.8.2

In /usr/lib/wx/python/
are these files:
Output:
wx3.0.pth wx.pth (a link to /etc/alternatives/wx.pth)
I already tried building Python from source (successfully/without errors) and installing with apt wx3.0-headers and wx-common. How can I get "import wx" working?

Thanks in advance for any hint, greetings
Peter

I've boiled down the script to this:

#!/usr/bin/python3

import wx
(Now the error occurs in line 3, not 6.)
Reply
#2
pip install wxpython
Reply
#3
Then it says:

Error:
Failed building wheel for wxpython
and finally:
Error:
checking for GTK+ - version >= 3.0.0... Package gtk+-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-3.0.pc' to the PKG_CONFIG_PATH environment variable 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 occured. This usually means GTK+ is incorrectly installed. configure: error: The development files for GTK+ were not found. For GTK+ 2, please ensure that pkg-config is in the path and that gtk+-2.0.pc is installed. For GTK+ 1.2 please check that gtk-config is in the path, and that the version is 1.2.3 or above. Also check that the libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config --libs' are in the LD_LIBRARY_PATH or equivalent. Error running configure ERROR: failed building wxWidgets Traceback (most recent call last): File "build.py", line 1468, in cmd_build_wx wxbuild.main(wxDir(), build_options) File "/tmp/pip-build-_bdcsH/wxpython/buildtools/build_wxwidgets.py", line 372, in main "Error running configure") File "/tmp/pip-build-_bdcsH/wxpython/buildtools/build_wxwidgets.py", line 85, in exitIfError raise builder.BuildError(msg) BuildError Finished command: build_wx (10.469s) Finished command: build (10.469s) Command '"/usr/bin/python" -u build.py build' failed with exit code 1. ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_bdcsH/wxpython/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-RshRBr-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-_bdcsH/wxpython/
Reply
#4
Should I better ask in a Ubuntu or Gtk forum than here?

Greetings
Peter
Reply
#5
Quote:No package 'gtk+-3.0' found
Quote:*** Could not run GTK+ test program, checking why...
looks like you have not installed the dependencies required to build wxpython
    $ sudo apt-get update

    $ sudo apt-get install dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl1.2-dev libgstreamer-plugins-base0.10-dev libnotify-dev freeglut3 freeglut3-dev libwebkitgtk-dev libghc-gtk3-dev libwxgtk3.0-gtk3-dev
Reply
#6
did you try to download a wheel for linux from https://wxpython.org/pages/downloads/

and this is the direct link https://extras.wxpython.org/wxPython4/extras/linux/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
@joe_momma:

I get this error when I envoke the second shell command you mentioned:
Error:
Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libgstreamer-plugins-base0.10-dev E: Couldn't find any package by glob 'libgstreamer-plugins-base0.10-dev' E: Couldn't find any package by regex 'libgstreamer-plugins-base0.10-dev'
@buran: OK I downloaded the wheel. And what I'm going to do with it?

Greetings
Peter
Reply
#8
(Mar-31-2020, 10:56 AM)PeterLinux Wrote: And what I'm going to do with it?
install it locally

Output:
$ pip install path_to_whl/whl_file.whl
Just noticed you are on 3.8, and wheels are up to 3.7. Not sure if this may cause any problems
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
I typed:

Quote:pip install wxPython-4.0.7.post2-cp37-cp37m-linux_x86_64.whl
And got this error:
Error:
wxPython-4.0.7.post2-cp37-cp37m-linux_x86_64.whl is not a supported wheel on this platform.
Huh? I'm on a 64bit (x86_64) system and my python is 64 bit (I checked that).

I've read in a thread with a similar problem that Python 3.8 isn't stable:
https://python-forum.io/Thread-ModuleNot...3-8-Alfa-0

I use Python 3.8.2. Maybe that's the problem?
Reply
#10
(Mar-31-2020, 11:36 AM)PeterLinux Wrote: I've read in a thread with a similar problem that Python 3.8 isn't stable:
The other thread refer to 3.9 which is unstable (not yet released). 3.8 is latest stable version. However, it looks like the problem is that wheel is for 3.7 and you are on 3.8. As I said, I didn't notice that initially and didn't check whl for what python version are available
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] ModuleNotFoundError: No module named 'PyQt5' matklt 2 16,585 Jun-02-2020, 07:05 AM
Last Post: Knight18
  [Kivy] ModuleNotFoundError: No module named 'kivy' Exsul 7 30,050 Mar-30-2019, 12:58 AM
Last Post: Exsul
  "ModuleNotFoundError: No module named '_tkinter' in Python 3.8 Alfa 0 programmerc 1 6,283 Oct-21-2018, 06:32 PM
Last Post: Larz60+
  PyGtk3, No Module Named gi, on python3.5 on Windows harun2525 8 34,324 May-19-2017, 01:30 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020