18
votes

So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows?

Thanks

9
It might be worth giving uis some more information. Which operating system which python version and which downloads did you try. ? - rgammans
Please provide more details as to what have you tried and what is the exact problem in terms of coding that you are facing so that people can help you out. - Girish Sortur
my python is version 3.4.3, and i think that it's 32-bit. my OS is windows 7 and i've 32-bit. I've downloaded all four of the options: 32-bit Python 2.6; 64-bit Python 2.6; 32-bit Python 2.7 and 64-bit Python 2.7; they were under the title 'Windows Binaries', and I've also downloaded the demo for Windows. - oisinvg

9 Answers

14
votes

It's on PyPI. As of wxPython 4, Python 3 is supported.

Unfortunately, PyPI has a package called wx that is stuck at version 3.0.3; be sure to install the package named wxpython instead.

pip install wxpython

Please note that pip will automatically build wxWidgets for you, but it will not install wxWidgets system dependencies such as GTK and OpenGLu. If the above command exits with an error, look above for a message like this:

checking for <something>... not found
checking for <something>... no
configure: error: <prereq> libraries not available
Error running configure
ERROR: failed building widgets

This should give you information about at least one of the packages your system is missing.

The "official" list of prerequisites from the wxWidgets source is:

  • dpkg-dev
  • build-essential
  • libjpeg-dev
  • libtiff-dev
  • libsdl1.2-dev
  • libgstreamer-plugins-base0.10-dev # or 1.0 if available
  • libnotify-dev
  • freeglut3
  • freeglut3-dev
  • libsm-dev
  • libgtk-3-dev
  • libwebkitgtk-3.0-dev # or libwebkit2gtk-4.0-dev if available
  • libxtst-dev

The actual package names provided by your package manager may not match these exactly, and to be honest, I don't really know the best way to query a package manager to determine what packages provide the libraries you need.

7
votes

3 steps to install wx-widgets and pygame in python IDLE

  1. Install python 3xxx in your system opting (Add 3xxx to your path).
  2. open python CLI to see whether python is working or not.
  3. then open command prompt (CMD).
    • type PIP to see whether pip is installed or not.
  4. enter command : pip install wheel
  5. enter command : pip install pygame
  6. To install wxpython enter command : pip install -U wxPython

Thats all !!

5
votes

As per home page instruction:

Make sure you have at least version 6.0.8 of pip and 12.0.5 for setuptools.

Install requirements for Linux as outlined in the readme.rst at:

    https://github.com/wxWidgets/Phoenix/blob/master/README.rst 

Install wxPython-Phoenix (Linux):

       sudo pip install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix 

Install wxPython-Phoenix (Windows, use the appropriate script folder):

       C:\python27\scripts\pip.exe install --upgrade  --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix 
1
votes

To install wxPython GUI library correctly go to the following page (https://wxpython.org/Phoenix/snapshot-builds/), which contains snapshots builds of wxPython library (Phoenix version) depending on your os and version of Python you want to work.

Then when you downloaded the proper package for your system and python version, simply install it by using pip. In my case I've choosen that one (wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl):

pip install wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl

To check that it has been installed sucessfully on the site-packages folder for your current python environment write:

pip freeze

It's all!

1
votes

I installed wxPython as part of the PsychoPy experiment builder dependencies, and had considerable trouble getting it to install properly as well initially. But this was what worked for me at the end. I use Ubuntu 16.04, python 3.5, pip3 19.0.3

pip3 install -U     -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04     wxPython --user
1
votes

If you use Conda then you may easily setup the environment with wx by one line:

$ conda create -n wxenv python=3 wxPython
Solving environment: done

## Package Plan ##

  environment location: /home/user/.conda/envs/wxenv

  added / updated specs: 
    - python=3
    - wxpython


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    [...]
Proceed ([y]/n)? 
0
votes

You need to ensure the versions of your wxPython download matches your installed python language library.

The current downloads wxPython downloads doesn't show any libraries built against python 3. I Believe the python 3 porting project is still ongoing.

If you are not sure of what you are doing I would stick with the 32bit version on windows as there are some Python libraries (ie IIRC, MySQLdb) which don't work with 64 bit python.

So you would then need to download python2.7 for windows x86 and "wxPython3.0-win32-py27 32-bit Python 2.7"

0
votes

Check the version of wxpython and the version of python you have in your machine. For python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package

0
votes

The problem was solved in openSuse simply with

zypper in python-wxWidgets-3_0-devel

Trying pip install before, gave me a lot of trouble (missing traits, missing wx/setup.h, https://github.com/wxWidgets/Phoenix/issues/1644, error: aggregate ‘wxGLAttributes _NullGLAttributes’ has incomplete type and cannot be defined, etc.).