wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.23k stars 510 forks source link

error in installing wxPython on windows #2024

Closed rkadam61001 closed 2 years ago

rkadam61001 commented 2 years ago
 your issue rC:\Users\HP>pip install -U wxPython

Collecting wxPython Using cached wxPython-4.1.1.tar.gz (66.0 MB) Preparing metadata (setup.py) ... done Requirement already satisfied: pillow in c:\python\lib\site-packages (from wxPython) (8.4.0) Requirement already satisfied: six in c:\python\lib\site-packages (from wxPython) (1.16.0) Requirement already satisfied: numpy in c:\python\lib\site-packages (from wxPython) (1.21.4) 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: Command errored out with exit status 1: command: 'C:\python\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\HP\AppData\Local\Temp\pip-install-72by_mwf\wxpython_a8f2bd6de2d945b69743e5fd61117a3b\setup.py'"'"'; file='"'"'C:\Users\HP\AppData\Local\Temp\pip-install-72by_mwf\wxpython_a8f2bd6de2d945b69743e5fd61117a3b\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-pmvep6e2\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\python\Include\wxPython' cwd: C:\Users\HP\AppData\Local\Temp\pip-install-72by_mwf\wxpython_a8f2bd6de2d945b69743e5fd61117a3b\ Complete output (49 lines): C:\python\lib\site-packages\setuptools\dist.py:697: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead warnings.warn( running install running build C:\Users\HP\AppData\Local\Temp\pip-install-72by_mwf\wxpython_a8f2bd6de2d945b69743e5fd61117a3b\build.py:41: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives from distutils.dep_util import newer, newer_group Will build using: "C:\python\python.exe" 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] Python's architecture is 64bit cfg.VERSION: 4.1.1

Running command: build
Running command: build_wx
Command '"C:\python\python.exe" -c "import setuptools, distutils.msvc9compiler as msvc; mc = msvc.MSVCCompiler(); mc.initialize(); print(mc.cc)"' failed with exit code 1.
Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "C:\python\lib\distutils\msvc9compiler.py", line 371, in initialize

    vc_env = query_vcvarsall(VERSION, plat_spec)

  File "C:\python\lib\site-packages\setuptools\msvc.py", line 140, in msvc9_query_vcvarsall

    return EnvironmentInfo(arch, ver).return_env()

  File "C:\python\lib\site-packages\setuptools\msvc.py", line 1740, in return_env

    [self.VCIncludes,

  File "C:\python\lib\site-packages\setuptools\msvc.py", line 1282, in VCIncludes

    return [join(self.si.VCInstallDir, 'Include'),

  File "C:\python\lib\site-packages\setuptools\msvc.py", line 840, in VCInstallDir

    raise distutils.errors.DistutilsPlatformError(msg)

distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Finished command: build_wx (0.265s)
Finished command: build (0.265s)
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:\python\python.exe" -u build.py build
Command '"C:\python\python.exe" -u build.py build' failed with exit code 1.
----------------------------------------

ERROR: Command errored out with exit status 1: 'C:\python\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\HP\AppData\Local\Temp\pip-install-72by_mwf\wxpython_a8f2bd6de2d945b69743e5fd61117a3b\setup.py'"'"'; file='"'"'C:\Users\HP\AppData\Local\Temp\pip-install-72by_mwf\wxpython_a8f2bd6de2d945b69743e5fd61117a3b\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-pmvep6e2\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\python\Include\wxPython' Check the logs for full command output.

swt2c commented 2 years ago

Hi, unfortunately, wxPython 4.1.1 doesn't build on Python 3.10 on Windows currently, see #2016. That needs to be fixed first. As a workaround you could try Python 3.9 for now.

KubaO commented 2 years ago

Best I can tell, this issue is not Python 3.10-specific. It rears its ugly head anytime a modern version of Visual Studio is installed in lieu of MSVC 2015 or something older (shudder).

swt2c commented 2 years ago

Well, there's definitely a Python 3.10 issue on Windows. If the OP wants to provide more details, we could investigate. However, this error is coming from distutils, so there's not likely anything we can do about it in wxPython.

oleksis commented 2 years ago

Hi @rkadam61001 cc: @swt2c

I think the issue is setuptools.msvc and how manage the redist_path and prefixes with Microsoft C++ Build Tools in Visual Studio 2019

You can check more in the gist: Compile wxPython 4.1.2a1 using Microsoft C++ Build Tools 2019

bromelio commented 2 years ago

I have the same issue with wxPython, Python 3.10 and Visual Studio 2019. Will this be fixed on wxPython's side? I imagine many more wxPython users on Windows are affected...

rmaia3d commented 2 years ago

Had Python 3.10.1 installed with VS2022 and 2019 build tools installed and configured properly. Couldn't build the wxpython whl that was generated/downloded by running "pip install wxpython". Reading through the previous answers, rolled back my Python version to 3.9.9. Then was able to install through the same pip command successfully. So indeed it looks like a Python 3.10 problem.

oleksis commented 2 years ago

Had Python 3.10.1 installed with VS2022 and 2019 build tools installed and configured properly...

For Python 3.10 and wxPython 4.1.2a1 I recommend that you clone the git repository and submodules from GitHub

Have VS2022 and 2019 Build Tools and following this comment compiles successfully

python -c "import wx; print(wx.version());"
4.1.2a1 msw (phoenix) wxWidgets 3.1.5
kdschlosser commented 2 years ago

I want to have someone run some tests for me with a script I wrote. I wrote a COM binding to Visual Studio to enumerate all installations of Visual Studio and MSVC. The script will detect all installations of Visual C 2008 and newer and all installations if Visual Studio It detects all Windows SDK's starting from 6.0a up to the newest Windows 11

It creates an identical build environment that Visual C and Visual Studio creates. It doe this without using the vcvars*.bat files that come with Visual C and Visual Studio. Those files have never really worked properly and have been proven to be problematic at best and I do not understand why distutils and also setuptools continually uses them.

run the msvc.py file then copy and paste the output into a post. Let me know the Visual Studio version, Windows SDK, MSVC build tools version you have installed and I will check the output to make sure it is correct.

If someone wants to test it to see if it fixes the compiling problems you can drop those 2 files into the same folder as the setup.py file for wxPython and then edit setup.py file and add this one single line at the top import msvc and that is all that needs to be done to make the script work.

Python MSVC build environment.zip

rkadam61001 commented 2 years ago

issue solved

oleksis commented 2 years ago

@kdschlosser

It looks very interesting and returns a lot of information about the environment! You have some master repository to fork. https://github.com/kdschlosser/python_msvc ???

Hire how i tested:

python -m pip install --upgrade pip setuptools wheel
virtualenv venv
.\venv\Scripts\activate
pip install comtypes
python .\msvc.py
kdschlosser commented 2 years ago

The information it is telling you is not just information for informative purposes that information that is collected is what gets used to create the build environment. By adding the import of the module to the top of the setup.py file for wxPython the script will load and set the build environment. Give it a try and compile wxPython with it.

Yes that is a link to the repository for it. I just pushed a commit to it a few hours ago.

The nice thing about what I have done is I am using COM interfaces to collect a large portion of the information from the system. I technically have it incorrectly named as I thought the COM interfaces where made available by vswhere but as it turns out vswhere uses the same com interfaces to work just like what I am doing. I have exposed a whole lot more information then what vswhere provides.

Right now if you have more then one version of visual c installed you can tel the program what compiler to use, you can also specify an SDK to use if you have more then one installed. UCRT comes pre installed into the Windows 10SDK's so if you wanted to compile something that uses UCRT except say you wanted to use the Windows 7 SDK you would install a Windows 10 SDK along side the Windows 7 SDK and the script will use the UCRT headers and libs from the Windows 10 SDK.

I will also be adding support for specifying which toolkit to compile with and the .NET framework as well.

To handle most compiling needs just add the 2 files and import msvc at the top of the setup.py file.

Do you mind posting a copy of the output from the script? I would like to make sure all is correct with it and if any adjustments need to be made I will make them.

oleksis commented 2 years ago

@kdschlosser Here the active issue

We could adapt msvc.py for use with build.py ?

kdschlosser commented 2 years ago

easily. Just import msvc at the top of build.py

ghost commented 2 years ago

I am also having issues. Here is the log. I am not very python-savvy; but am willing to help anyone debug this issue. Would love to get this up and running as I need to develop an GUI based python code soon and would need this resolved

× Running setup.py install for wxPython did not run successfully. │ exit code: 1 ╰─> [30 lines of output] C:\Users\xxxxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py:717: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead warnings.warn( C:\Users\xxxxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py:294: DistDeprecationWarning: use_2to3 is ignored. warnings.warn(f"{attr} is ignored.", DistDeprecationWarning) running install running build C:\Users\xxxxx\AppData\Local\Temp\pip-install-30mec1_5\wxpython_4d1aaa04159842a19252012945ab6e3d\build.py:41: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives from distutils.dep_util import newer, newer_group Will build using: "C:\Users\xxxxx\AppData\Local\Programs\Python\Python310\python.exe" 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] Python's architecture is 64bit cfg.VERSION: 4.1.1

  Running command: build
  Running command: build_wx
  MSVC: cl.exe
  wxWidgets build options: ['--wxpython', '--unicode']
  creating wx/msw/setup.h from setup0.h
  setting build options...
  Command 'cl.exe' failed with exit code 1.
  Finished command: build_wx (0m1.132s)
  Finished command: build (0m1.132s)
  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\xxxxxx\AppData\Local\Programs\Python\Python310\python.exe" -u build.py build
  Command '"C:\Users\xxxxxx\AppData\Local\Programs\Python\Python310\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

oleksis commented 2 years ago

Try apply the PR #2085 or use the msvc-build-environment branch

swt2c commented 2 years ago

Or, if you don't actually care about building wxPython yourself, you could install one of the snapshot builds for Python 3.10: https://wxpython.org/Phoenix/snapshot-builds/

wxPython 4.1.1 can't be built for Python 3.10 without applying additional fixes on top.

michael-letcher commented 2 years ago

Couldn't install on Window 11 & Python 3.10.4. Downgraded to 3.9.12 worked

BaasithFazil commented 1 year ago

after downgrading my python version from 3.10 to 3.9. wxpython installing success but at the end i had an error "setup.py install for wxpython ... error". How to solve this?

oleksis commented 1 year ago

Read this comment for install wxPython on Windows

Harishmvl commented 1 year ago

issue solved

Can you please tell me the steps to solve the Issue