Trying to install wxPython on Windows

I am trying to install the current wxPython on Windows with
pip install -U wxPython
as recommended on wxPython Downloads | wxPython

but no matter whether I try to do this within VSCode or in PS shell, I get the same error

PS D:\pkg\Python\work\wpSkAui> pip install -U wxPython  
Collecting wxPython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in c:\users\arnold\appdata\local\programs\python\python38-32\lib\site-packages (from wxPython) (9.2.0)
Requirement already satisfied: six in c:\users\arnold\appdata\local\programs\python\python38-32\lib\site-packages (from wxPython) (1.12.0)
Requirement already satisfied: numpy in c:\users\arnold\appdata\local\programs\python\python38-32\lib\site-packages (from wxPython) (1.23.3)
Using legacy 'setup.py install' for wxPython, since package 'wheel' is not installed.
Installing collected packages: wxPython
  Running setup.py install for wxPython ... error
  error: subprocess-exited-with-error

  × Running setup.py install for wxPython did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      running install
      running build
      Will build using: "c:\users\arnold\appdata\local\programs\python\python38-32\python.exe"
      3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)]    
      Python's architecture is 32bit
      cfg.VERSION: 4.2.0
     
      Running command: build
      Running command: build_wx
      Command '"c:\users\arnold\appdata\local\programs\python\python38-32\python.exe" -c "import os, sys, setuptools.msvc; setuptools.msvc.isfile = lambda path: path is not None and os.path.isfile(path); ei = setuptools.msvc.EnvironmentInfo('x86', vc_min_ver=14.0); env = ei.return_env(); env['vc_ver'] = ei.vc_ver; env['vs_ver'] = ei.vs_ver; env['arch'] = ei.pi.arch; env['py_ver'] = sys.version_info[:2]; print(env)"' failed with exit code 1.
      Traceback (most recent call last):
     
        File "<string>", line 1, in <module>
     
      AttributeError: 'EnvironmentInfo' object has no attribute 'vs_ver'
      Finished command: build_wx (0.208s)
      Finished command: build (0.209s)
      WARNING: Building this way assumes that all generated files have been
      generated already.  If that is not the case then use build.py directly
      to generate the source and perform the build stage.  You can use
      --skip-build with the bdist_* or install commands to avoid this
      message and the wxWidgets and Phoenix build steps in the future.
     
      "c:\users\arnold\appdata\local\programs\python\python38-32\python.exe" -u build.py build
      Command '"c:\users\arnold\appdata\local\programs\python\python38-32\python.exe" -u build.py build' failed with exit code 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> wxPython

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
PS D:\pkg\Python\work\wpSkAui>

FWIW & IIRC, I had to install another package ???_attrib, which seemed to get me a bit further along the way, but now I am stuck
As this is a test machine, I now have several versions of Python installed.

PS D:\pkg\Python\work\wpSkAui> py -0
Installed Pythons found by C:\WINDOWS\py.exe Launcher for Windows
-3.10-64 *
-3.9-64
-3.9-32
-3.8-32
-3.7-64

If possible I would prefer to not remove any of the older versions to avoid issues with other projects.

Your pip call tries to install for Python 3.8 32 bit.
wxPython does not have binaries for 32 bit any more, as you can see from here: wxPython · PyPI

You may install e.g. for 3.10 64 bit, though.

So better use

# within the directory of Python 3.10 64 bit:
python -mpip install wxPython

# from any directory:
"Path to Python 3.10 64 bit\python" -mpip install wxPython

This way you can control for which Python version you are installing.

Thank you.
The only problem I had was finding the correct directory to run the command in :slight_smile:
and then to ensure I would use the correct python interpreter, I had to add the prefix "./’ to your command

As I recall, if you use pycharm you can have different versions of python installed in different virtual environments.

I would be suprised if there was an IDE that does not allow to specify the interpreter path.

I don’t use virtual environments, but isn’t their purpose to have different library configurations within the same interpreter?

As a former (now retired) developer/maintenance programmer, I preferred to use virtual machines that duplicated the target environments specifically to prevent contamination. But where resources are limited I can see the attraction of having virtual environments on one machine. Since I program now mostly for my own use I didn’t explore pycharm’s VE capability but I’m pretty sure you can have not only different library configs, but also different python versions as well. Convenient for anyone who still has to maintain 2.x versions.

Some IDEs like idle, and likely Visual Studio (still an excellent debugger) do not support virtual environments. I don’t know about WingIDE.