0

So I'm using python 3.3 and recently I have tried to install wxpython and wxwidgets. Synaptic package manager shows that wxversion, wxtools and wxgtk2.8 are all installed. When I use the python idle I get an import error however when I use iPython (command line with auto complete etc...) it happily runs the code.

What's going on?

Error Message:

Traceback (most recent call last):
    File "<pyshell#0>", line 1, in <module> import wx
ImportError: No module named 'wx'
Habib
  • 219,104
  • 29
  • 407
  • 436
Reubens
  • 55
  • 1
  • 1
  • 6

3 Answers3

1

IPython must be running Python 2.x because wxPython 2.8.x ONLY works with Python 2.x. If you want to use wxPython in Python 3, you have to use wxPython 2.9-Phoenix. Please note the Phoenix is kind of alpha in that ONLY the core widgets are currently available in it.

You can read more about it and download it from here:

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
0

in your python shell at the very top, it will tell you what bit your python runs on. It's either 32bit or 64 bit. now once you have that info wxpython has two different bit varients depending on what python version your running, again either 32bit or 64 bit. If you have the python 32bit version you must use the wxpthon 32bit for the import to work.

I had this mistake also and figured it out this way. Good Luck!!

-1

First let's See what version of Python we're running:

python --version

Looks like we have Python running version 3.

Python 3.3.0

That won't work.

Remove Python 3:

sudo apt-get remove python3

Let's reinstall Python but version 2.7:

sudo apt-get install python2.7 wx-common python-wxtools python-wxgtk3.0

  • 1
    I'm not sure this is the best advice. The assumption that we are on some sort of Debian OS is ok I guess, but removing Python could break a lot of stuff, including apt itself, no? Furthermore, at this time, Python 3 and 2.x can co-exist quite well if you install from apt repos, and I recall it defaults to 2.7 for the python command itself. –  Sep 16 '17 at 14:56