Python ImportError: No module named wx
Solution 1
Ubuntu:
sudo apt-get install python-wxtools
Solution 2
For Windows and MacOS, Simply install it with pip
pip install -U wxPython
Reference: Official site
Solution 3
Windows:
Go to
C:\Python27\Lib\site-packages\
find the folderwx-<version>-msw
or similarMove the
wx
from the above folder toC:\Python27\Lib\site-packages\
Solution 4
I had the same error today but I tried something and surprisingly it worked. In the site packages folder there will be a file named wx.pth. Open it using notepad and its contents would be like "wx-2.8-msw-unicode"
It is basically the name of the folder containing wxpython
. Delete this using Ctrl + A and copy the name of the folder from the site packages and paste it here even if it is the same.
Sounds weird but maybe the original file contained a hidden character...
Solution 5
I had the same problem for a PyMOL plugin that required the wx module, though I installed wxpython by downloading its package from here (Unofficial Windows Binaries for Python Extension Packages) and installing it with the command:
pip install .\wxPython-3.0.2.0-cp27-none-win_amd64.whl
For some reason it gave me that error, for which I uninstalled it with:
pip uninstall wxPython
and then I downloaded it from here (wxPython 4.0.0a1) and reinstalled:
pip install .\wxPython-4.0.0a1-cp27-cp27m-win_amd64.whl
The error at this point has not been presented anymore.

Luke Bream
Updated on July 09, 2022Comments
-
Luke Bream 6 months
Im sorry to ask this question again. I have searched and found endles repeats of it both on stackoverflow and also on general google search. Unfortunatly I just cant get my system sorted.
I have the following:
C:\Python27\Lib\site-packages\wx-2.8-msw-unicode
this folder contains the wx folder and also wx & wxPython folders which each contain the
_init_.py
filesWhen I import wx I get the error message
"no module named wx"
What do I need to do in order to get Python to find the relevant files to allow me to "import wx" succesfully
-
joaquin about 11 yearsplease, don't do that, the name is correct. If you installation has been done properly there should be a file wx.pth in site-packages pointing to that folder name.
-
Luke Bream about 11 yearsHi....I have checked the site-packages folder and I do have the wx.pth file present....and it contains the follwoing single line
wx-2.8-msw-unicode
any suggestions for sorting this would be really appreciated ! -
Mateusz over 6 yearshe uses windows, not ubuntu/debian
-
Samuel almost 6 yearsThis failed with compile errors for me, using Python 2.7.
-
philshem almost 6 yearsThis worked for me after I installed wx from Unofficial Windows Binaries for Python Extension Packages
-
philshem almost 6 yearsIf the pip installation fails, you should install the binary from lfd.uci.edu/~gohlke/pythonlibs
-
philshem almost 6 yearsFYI - this installation requires windows admin rights
-
paxdiablo almost 4 yearsThe fact OP has in the question
C:\Python27\Lib\site-packages\wx-2.8-msw-unicode
means this answer will be rather less than useful. -
sijo0703 over 3 yearsThis command worked for me:: pip install wxPython
-
Giuseppe Urso over 3 yearsYes but that's because python 2.7 is default on your system, try pip3
-
Nelda.techspiress almost 2 yearsDownload link: wxpython.org/pages/downloads
-
rayzinnz almost 2 yearsfor linux too, this is the best way
-
Meep about 1 yearAs per the site, for linux distro dependent, example: pip install -U \ -f extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 \ wxPython