oisinvg
oisinvg

Reputation: 670

How to properly install wxPython?

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

Upvotes: 26

Views: 128420

Answers (12)

Danie van Eeden
Danie van Eeden

Reputation: 1

Note that I tried to install wxPython with 'pip install -U wxPython' as per instruction with no avail. Too many errors to list here. 🤨

I found a solution to the problem!!

I'm working on a 64b machine and Windows 11 operating system using VSCode.

Here is the solution using PowerShell:

Version specs:

  • pip 22.3.1
  • virtualenv 20.15.1
  • python 3.10.8

Create a new virtual environment in the directory where the program resides and activate. There must be no modules installed.

  • virtualenv venv
  • venv/scripts/activate.bat

Install the following in sequence:

  • pip install pygame (Not sure why pygame must be installed first, but this was recommended and it works) 😟
  • pip install -U wxPython

SUCCESS!!! 🤠

These are the modules installed:

  • numpy 1.24.1
  • Pillow 9.4.0
  • pip 22.3.1
  • pygame 2.1.2
  • setuptools 65.4.0
  • six 1.16.0
  • wheel 0.37.1
  • wxPython 4.2.0

VSCode still reports wx as a missing module even when you activate the virtual environment within. Running the code from the PS command prompt within the virtual environment is the only working solution.

PS. I am sure there are some conflicts when trying to install wxPython within an environment where all the other modules are installed.

Upvotes: 0

Ahmed sassi
Ahmed sassi

Reputation: 1

Install current development version with:

pip install -U https://github.com/robotframework/RIDE/archive/master.zip (python < 3.9) Install current Beta version (2.0b1) with:

pip install psutil pip install -U --pre robotframework-ride

Upvotes: 0

Umair A.
Umair A.

Reputation: 6873

wxpython failed to be installed with pipenv. Pipenv is not able to find wxpython binary so it tries to build wxpython but fails.

CXXFLAGS="-I/opt/homebrew/include" pipenv install wxpython

On my macOS M1 pipenv failed to install wxPython. After a lot of searching I found a forum post which really helped me fix the problem.

Source/Credits: https://forums.wxwidgets.org/viewtopic.php?t=47953&p=203709

Upvotes: 0

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.).

Upvotes: 0

nosbor
nosbor

Reputation: 2999

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)? 

Upvotes: 1

Tokaalmighty
Tokaalmighty

Reputation: 402

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

Upvotes: 4

Jyoti Panda
Jyoti Panda

Reputation: 11

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

Upvotes: 0

Kyle Strand
Kyle Strand

Reputation: 16499

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.

Upvotes: 22

jrk
jrk

Reputation: 185

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 !!

Upvotes: 8

Guiloga
Guiloga

Reputation: 1

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!

Upvotes: 0

Serg Kryvonos
Serg Kryvonos

Reputation: 4677

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 

Upvotes: 5

rgammans
rgammans

Reputation: 356

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"

Upvotes: 0

Related Questions