- wxPython - Home
- wxPython - Introduction
- wxPython - Environment
- wxPython - Hello World
- wxPython - GUI Builder Tools
- wxPython - Major Classes
- wxPython - Event Handling
- wxPython - Layout Management
- wxPython - Buttons
- wxPython - Dockable Windows
- Multiple Document Interface
- wxPython - Drawing API
- wxPython - Drag and Drop
- wxPython Resources
- wxPython - Quick Guide
- wxPython - Useful Resources
- wxPython - Discussion
wxPython - Environment Setup
To set up the environment for wxPython, it is recommended to use the pip package manager, as it simplifies downloading and installing Python packages. In this chapter, we will cover how to install the wxPython package on your computer.
Installing wxPython using pip
To install wxPython using pip3, just run the below command in your command prompt −
pip3 install wxPython Collecting wxPython Downloading wxpython-4.2.5-cp314-cp314-win_amd64.whl.metadata (3.7 kB) Downloading wxpython-4.2.5-cp314-cp314-win_amd64.whl (16.9 MB) ... Installing collected packages: wxPython Successfully installed wxPython-4.2.5
How to Install wxPython on MacOS?
Installing wxPython in a Python environment on macOS is straightforward and can be done using package management tools like pip or conda.
Follow the below steps to set up wxPython on macOS −
Open Terminal: We can access the Terminal application on macOS from the Applications folder under Utilities.
Check Python Version: It's a good practice to ensure we have Python installed. To check our Python version to run the following command −
py --version python 3.14.2
Install 'pip' (if not already installed): Most recent versions of Python come with pip pre-installed. To check if pip is installed we can run −
pip --version pip 26.0
If it's not installed, we can install it by downloading the get-pip.py script and running it with Python. Download the script using curl −
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then run the following script.
py get-pip.py
Install wxPython: And finally install wxPython using pip by simply run the following command.
pip3 install wxPython
This command will download and install wxPython and its dependencies.
Now we have successfully set up the wxPython library in our macOS Python environment. We can now start using wxPython.
How to Install wxPython on Windows?
To install the Python wxPython or its more up-to-date fork on Windows we can follow these steps −
Install Python: If we haven't already installed Python on our Windows system we can do so by following these steps −
Download the latest Python installer for Windows from the official Python website (https://www.python.org/downloads/windows/).
Run the installer and during installation and make sure to check the option Add Python X.Y to PATH (replace X.Y with the Python version we are installing).
Verify Python Installation: Open a command prompt and check that Python has been installed successfully by running the below code −
py --version
Install wxPython (Recommended): wxPython is the modern fork of PIL and is more actively maintained. To install wxPython open a command prompt and run the following command −
pip3 install wxPython
This command will download and install wxPython and its dependencies on our Windows system.
How to Install wxPython on Linux?
Setting up the wxPython library in a Python environment on a Linux-based operating system is similar to the process on macOS. Here are the steps for setting up the environment for wxPython on Linux.
Check Python Installation: Most Linux distributions come with Python pre-installed. To check if Python is installed first open the terminal and run the following code.
py --version
Make sure we have Python 3.x installed as Python 2 is no longer supported.
Install 'pip' (if not already installed): Most recent versions of Python come with pip pre-installed. To check if pip is installed, run the following code.
pip3 --version
If it's not installed we can install it using the package manager specific to our Linux distribution. For example on Debian/Ubuntu-based systems run the following commands based on the OS.
sudo apt-get install pip
On Red Hat/CentOS-based systems
sudo yum install pip
Install wxPython: To install wxPython using pip and run the below command −
pip3 install wxPython
This command will download and install wxPython and its dependencies.
Virtual Environment (Optional but Recommended)
It's a good practice to create a virtual environment for our Python projects to keep dependencies isolated. We can create a virtual environment using the following command −
py -m venv myenv
Replace myenv with the name we want for our virtual environment. To activate the virtual environment run the below code −
source myenv/bin/activate
Now we can use our virtual environment to work on Python projects that require wxPython.