Current Release
Starting with wxPython 4.0 (the first Phoenix release) the wxPython sourcearchive and, for supported platforms, wxPython binary wheels are availablefrom the Python Package Index (PyPI). wxPython’s project page at PyPI ishttps://pypi.org/project/wxPython.
The source or binary wheels can be downloaded directly from the projectpage, or you can use the wonderful piptool to do it for you.
Install Compose. Follow the instructions below to install Compose on Mac, Windows, Windows Server 2016, or Linux systems, or find out about alternatives like using the pip Python package manager or installing Compose as a container. Install a different version. Doing it Right¶. Let’s install a real version of Python. Before installing Python, you’ll need to install GCC. GCC can be obtained by downloading Xcode, the smaller Command Line Tools (must have an Apple account) or the even smaller OSX-GCC-Installer package. Pip is a tool for easily installing and managing Python packages, that is recommended over easyinstall. It is superior to easyinstall in several ways, and is actively maintained. $ pip2 -V # pip pointing to the Homebrew installed Python 2 interpreter $ pip -V # pip pointing to the Homebrew installed Python 3 interpreter (if installed).
Windows and macOS
If you are on Windows or macOS with a compatible Python build, then thecommand shown above will download the appropriate wheel file from thelatest release, and install it in your active Python environment or virtualenvironment.
If there is no binary wheel file available for your platform or for yourversion of Python, then pip will download the source archive and willattempt to build it for you. There is some information about that below.
Yes, we have Linux Wheels. Sort of.
Because of the differences between Linux distributions (mainly differentversions of the core libraries installed by default, but also platformarchitecture and etc.) it is not possible to host binary wheel files forLinux on PyPI unless they can be made to work within the constraints ofPEP 513 Unfortunately,attempts to pound the wxPython peg into the manylinux1
hole have not beenvery successful. Maybe manylinux2
will be a better fit. In the meantime,if you have a Linux similar enough to those used to build the wheelslocated under the wxPython Extras linux folder, then you can use them and not need to build the wheels yourself.
Since there are various options for distro and wx port (GTK2 or GTK3) thenthe files can not all be located in the same folder for easy access by pip.This simply just means that you’ll need to drill down a little further tofind the URL to give to pip. For example, to get the GTK3 wxPython buildsfor Ubuntu 16.04 (and 16.10, LinuxMint 18, and probably others) you can usea pip command like this:
Of course you can always download the wheel file yourself and then use pipto install your local copy of the file.
Building with Pip
If pip is not able to find a binary wheel file that matches your platformand your version of Python, then it will download the source archive andwill attempt to build it for you. If you have the required compiler anddependent libraries installed, then this will be a feasible approach foryou, although it can take some time to do the build. The end result will bethe same as if there was a binary wheel available for you. In fact, pip canalso be told to just build the wheel and not do the install. This way youcan reuse the wheel file for different Python environments or on othermachines, or whatever, without needing to rebuild for each one.
For instructions on how to build a wxPython wheel file specific to your Linuxmachine and Python installation, please refer to thispost in the blog.
Conda or Anaconda
If you are using a Python environment managed by Conda orAnaconda then you can install wxPython using theconda
tool just like you would install any other package. Checkhere for details on what builds areavailable. The fine folks at Conda-forge have done agood job at keeping it up to date with new releases.
One small gotcha to be aware of with the conda builds of wxPython is that onOSX/macOS you will need to use pythonw
to execute your wxPython applications,not the typical python
command. To use pythonw
you will need to install thepython.app
pacakge from conda.
Extra Files
In addition to the source and binaries available on PyPI, there are someextra files which are part of each release, which are hosted at https://extras.wxPython.org/wxPython4/extras/. The things you will find there are:
- A tarball containing the wxPython API documentation, which is thesame content available at https://docs.wxpython.org. You can use thiscopy of the reference docs for local off-line reading of the API referencematerial. Look for a file named like
wxPython-docs-VERSION.tar.gz
. - A tarball containing the wxPython demo and samples. It is highlyencouraged for new wxPython users, and experienced ones too, to downloadthis file. It is a great learning resource with tons of examples showinghow to use various components of the wxPython library. Look for a filenamed like
wxPython-demo-VERSION.tar.gz
. - Zip files with
*.pdb
files which are Visual Studio debugger information files. - Binary wheel files for a few flavors of Linux.
The Bleeding Edge
If you’re the daredevil type and prefer to work with the absolutely newestversion of wxPython, we’ve got a couple options for you.
Snapshot Builds
Each day that there are commits to wxPython Phoenix’s master branch, thebuildbot will attempt to do a ‘dailybuild’. If successful then the resulting wheels, docs, and source archiveswill be uploaded to the snapshots folder. Although these are not technically official releases, and may have new undiscovered and unsolved bugs, more than a few people use them successfully in their own projects.
GitHub
wxPython’s GitHub project is at https://github.com/wxWidgets/Phoenix. Ifyou want to tinker with the code (preferably in order to submit aPR) then this option is whatyou are looking for. Fork and clone a copy of the git repository foryourself and start tweaking away under the hood.
Since the generated files are not committed to git you will need to gothrough several more steps to generate and build the code, but they are allhandled by thebuild.py
script and there is a overview of the process and the needed steps in theREADME. Ifyou get stuck then you can ask about it on wxPython-dev.
Old Releases
The wxPython releases prior to 4.0 (a.k.a ‘Classic’ wxPython) will remainavailable atSourceForge.That includes source, documentation, the demo, and various binaryinstallers for Windows and Mac systems.
Note
Check out our guide for installing Python 3 on OS X.
Mac OS X comes with Python 2.7 out of the box.
You do not need to install or configure anything else to use Python. Having saidthat, I would strongly recommend that you install the tools and librariesdescribed in the next section before you start building Python applications forreal-world use. In particular, you should always install Setuptools, as it makesit much easier for you to install and manage other third-party Python libraries.
The version of Python that ships with OS X is great for learning, but it’s notgood for development. The version shipped with OS X may be out of date from theofficial current Python release,which is considered the stable production version.
Doing it Right¶
Let’s install a real version of Python.
Before installing Python, you’ll need to install a C compiler. The fastest wayis to install the Xcode Command Line Tools by runningxcode-select--install
. You can also download the full version ofXcode from the Mac App Store, or theminimal but unofficialOSX-GCC-Installerpackage.
Note
If you already have Xcode installed, do not install OSX-GCC-Installer.In combination, the software can cause issues that are difficult todiagnose.
Note
If you perform a fresh install of Xcode, you will also need to add thecommandline tools by running xcode-select--install
on the terminal.
Osx Pip Install Location
While OS X comes with a large number of Unix utilities, those familiar withLinux systems will notice one key component missing: a decent package manager.Homebrew fills this void.
To install Homebrew, open Terminal
oryour favorite OS X terminal emulator and run
The script will explain what changes it will make and prompt you before theinstallation begins.Once you’ve installed Homebrew, insert the Homebrew directory at the topof your PATH
environment variable. You can do this by adding the followingline at the bottom of your ~/.profile
file
Now, we can install Python 2.7:
Linux Pip Install Python 2.7
Because python@2
is a “keg”, we need to update our PATH
again, to point at our new installation:
Homebrew names the executable python2
so that you can still run the system Python via the executable python
.
Mac Osx Install Pip
Setuptools & Pip¶
Homebrew installs Setuptools and pip
for you.
Setuptools enables you to download and install any compliant Pythonsoftware over a network (usually the Internet) with a single command(easy_install
). It also enables you to add this network installationcapability to your own Python software with very little work.
pip
is a tool for easily installing and managing Python packages,that is recommended over easy_install
. It is superior to easy_install
in several ways,and is actively maintained.
Virtual Environments¶
A Virtual Environment (commonly referred to as a ‘virtualenv’) is a tool to keep the dependencies required by different projectsin separate places, by creating virtual Python environments for them. It solves the“Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keepsyour global site-packages directory clean and manageable.
For example, you can work on a project which requires Django 1.10 while alsomaintaining a project which requires Django 1.8.
To start using this and see more information: Virtual Environments docs.
This page is a remixed version of another guide,which is available under the same license.