Why do I see ImportError: No module named wx ?
Import wx FAILS
Installed python-2.7-16.msi , Checked it with Pyscripter and all is ok.
Next I try the wxPython install
(wxPython3.0-win32-3.0.2.0-py27.exe)
into c:\Python27\Lib\site-packages …. Clean install !
But Pyscripter reports ImportError: No module named wx Why?
It seems to me that PyScripter launches Python and Python scans the
code and sees import wx. Python then says I need to handle this import
but fails since it can’t find what it needs to handle import wx.
What is it looking for ?
Where is it looking ?
Thanks in advance for any assistance.
Bob
Why do I see ImportError: No module named wx ?
Import wx FAILS
Installed python-2.7-16.msi , Checked it with Pyscripter and all is ok.
Next I try the wxPython install
(wxPython3.0-win32-3.0.2.0-py27.exe)
into c:\Python27\Lib\site-packages …. Clean install !
But Pyscripter reports ImportError: No module named wx Why?
It seems to me that PyScripter launches Python and Python scans the
code and sees import wx. Python then says I need to handle this import
but fails since it can’t find what it needs to handle import wx.
What is it looking for ?
Where is it looking ?
Upon another suggestion:
I don’t think import wx works:
In Python 2.7.16 I try
copyright
… Responds with 4 Copyright statements
license()
… Responds with an extensive list of text
import wx
… Responds with ImportError: No module named wx
I think the interpreter is:
a. looking for file it cannot find, or
b. runs some script that generates the ImportError line
6 May 2020
As suggested wxPython was uninstalled then reInstalled
into c:\Python27\Lib\site-packages
Success and the install Readme says
“The self-installer package you have just installed contains the Python
extension modules, python modules and packages needed to run wxPython
applications. If you selected the “Make this install be the default
wxPython” option in the installer then this version will be the one
that is imported when apps do “import wx”. See the following wiki
page for more information about managing multiple installs:
Pyscripter’s File Change Notification has
C:\Python27\Lib\site-packages\wxversion.py checked and I click OK
import wxversion
wxversion.select(‘3.0’)
print (" Note - wxversion is 3.0 selected") # Still works
So I add the import wx statement … and ………… NO ERRORs
So it looks like the uninstall – reinstall resolved the issue.
Thanks to all.
Great job getting wx working on your Python 2.7 installation.
But since Python 2.7 is officially unsupported as of a few weeks ago, you really should try to move your project on to a Python 3 installation with a more up to date wx, if you can. The sooner you do this before investing a lot of time actually building your app, the less of a headache you will have.
Just to be clear, there is no installer .exe for any version of wxPython4. Like probably almost all other Python packages we have switched over to using the the PyPI service and the pip command-line utility. So to install the newest wxPython into a Python environment (whether it be a full install of Python or is a virtual env) you just need to do this:
pip install wxPython
Or, if you want to be sure that a specific Python instance is being used to run pip (recommended) then you can do it by running that specific Python executable, like this: