尝试在Windows上下载wxPython时出错



对python完全陌生,在命令行中运行命令' pip install -U wxPython ',这是我得到的错误:

C:UsersPikachu>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:userspikachuappdatalocalprogramspythonpython310libsite-packages (from wxPython) (9.1.0)
Requirement already satisfied: six in c:userspikachuappdatalocalprogramspythonpython310libsite-packages (from wxPython) (1.16.0)
Requirement already satisfied: numpy in c:userspikachuappdatalocalprogramspythonpython310libsite-packages (from wxPython) (1.22.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
╰─> [51 lines of output]
C:UsersPikachuAppDataLocalProgramsPythonPython310libsite-packagessetuptoolsdist.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:UsersPikachuAppDataLocalProgramsPythonPython310libsite-packagessetuptoolsdist.py:294: DistDeprecationWarning: use_2to3 is ignored.
warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
running install
running build
C:UsersPikachuAppDataLocalTemppip-install-2h0mnbulwxpython_9be5f59f193e4bde8c6b8e211acc73c3build.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:UsersPikachuAppDataLocalProgramsPythonPython310python.exe"
3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [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:UsersPikachuAppDataLocalProgramsPythonPython310python.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:UsersPikachuAppDataLocalProgramsPythonPython310libdistutilsmsvc9compiler.py", line 371, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:UsersPikachuAppDataLocalProgramsPythonPython310libsite-packagessetuptoolsmsvc.py", line 140, in msvc9_query_vcvarsall
return EnvironmentInfo(arch, ver).return_env()
File "C:UsersPikachuAppDataLocalProgramsPythonPython310libsite-packagessetuptoolsmsvc.py", line 1740, in return_env
[self.VCIncludes,
File "C:UsersPikachuAppDataLocalProgramsPythonPython310libsite-packagessetuptoolsmsvc.py", line 1282, in VCIncludes
return [join(self.si.VCInstallDir, 'Include'),
File "C:UsersPikachuAppDataLocalProgramsPythonPython310libsite-packagessetuptoolsmsvc.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.228s)
Finished command: build (0.228s)
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:UsersPikachuAppDataLocalProgramsPythonPython310python.exe" -u build.py build
Command '"C:UsersPikachuAppDataLocalProgramsPythonPython310python.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.

我的安装程序没有看到新的"visualstudio"。这帮助了我。也许你也是。

  1. 下载来源:wxPython-4.1.2a1-cp310-cp310-win_amd64.whl

  2. 安装:
  3. pip install _your_path_to_src_wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
    
  4. 测试:
  5. python -c "import wx; print(wx.version());"
    

如果一切正确,可能的输出:4.1.2a1 msw (phoenix) wxWidgets 3.1.5

更多细节:https://gist.github.com/oleksis/8637f096b97e18e00786e46465e97b34

最新更新