1

I'm trying to install wxPython on macOS and I have both Python 2.7 and Python 3 installed in parallel.

I've written a wxPython Hello World program in both versions. It works in Python 2, but in Python 3 I get this error message:

ModuleNotFoundError: No module named 'wx'.

It seems wxPython was only installed to Python 2.7 and Python 3 can't find it. How can I make it accessible from both versions?

1

2 Answers 2

0

I had the same problem. I reinstalled python 3.7 then installed wxPython. A quick reboot (not sure if that was even needed) and all is now working.

0

The official instructions for installing wxPython say

Windows and macOS

pip install -U wxPython

If you are on Windows or macOS with a compatible Python build, then the command shown above will download the appropriate wheel file from the latest release, and install it in your active Python environment or virtual environment.

As the wording hints to, this command only installs wxPython for your default python version. (In this case, that seems to be Python 2.)

Just like the command python is an alias for either python2 or python3, the command pip is an alias for either pip2 or pip3. If you want to make sure that you install a module for both versions of Python, you should run both commands:

pip2 install -U wxPython
pip3 install -U wxPython

However, this solution is not recommended because it doesn't work with all python versions. Instead, it is recommended to use python -m pip with your preferred version of python:

python2 -m pip install -U wxPython
python3 -m pip install -U wxPython

See also: Dealing with multiple python versions and PIP?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .