Last modified: May 26, 2025 By Alexander Williams

How to Install wxPython in Python

wxPython is a popular GUI toolkit for Python. It allows you to create desktop applications easily. This guide will help you install wxPython quickly.

Prerequisites for Installing wxPython

Before installing wxPython, ensure you have Python installed. You can check by running python --version in your terminal.


python --version

If Python is not installed, download it from the official website. wxPython works with Python 3.6 and above.

Install wxPython Using pip

The easiest way to install wxPython is using pip. Open your terminal or command prompt and run the following command.


pip install wxPython

This will download and install the latest version of wxPython. If you encounter errors, try upgrading pip first.

Verify wxPython Installation

After installation, verify it by running a simple Python script. Create a file named test_wxpython.py with the following code.


import wx

app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello wxPython")
frame.Show(True)
app.MainLoop()

Run the script using Python. If a window titled "Hello wxPython" appears, the installation was successful.


python test_wxpython.py

Install wxPython on Different Operating Systems

wxPython installation may vary slightly depending on your OS. Below are specific instructions for Windows, macOS, and Linux.

Install wxPython on Windows

Windows users can install wxPython directly using pip. Ensure you have the latest version of Python and pip.


pip install wxPython

Install wxPython on macOS

macOS users may need to install additional dependencies. Use Homebrew to install wxWidgets first.


brew install wxwidgets
pip install wxPython

Install wxPython on Linux

Linux users should install wxPython using their package manager. For Ubuntu or Debian, use the following command.


sudo apt-get install python3-wxgtk4.0

Common Installation Issues

Sometimes, you may face issues during installation. Here are some common problems and their solutions.

1. pip not found: Ensure pip is installed. You can install it using python -m ensurepip --upgrade.

2. Permission errors: Use pip install --user wxPython to install locally. Learn more about global vs local installations.

3. Missing dependencies: On Linux, install required libraries first. For example, on Ubuntu, run sudo apt-get install build-essential.

Using wxPython in Jupyter Notebook

You can also use wxPython in Jupyter Notebook. First, install it using pip. Then, create a new notebook and import wxPython.

For more details, check our guide on installing Python packages in Jupyter Notebook.

Conclusion

Installing wxPython is straightforward with pip. Follow the steps above for your operating system. Verify the installation by running a simple script.

wxPython is a powerful tool for building GUI applications. If you're interested in other GUI libraries, read our guide on installing PySide in Python.