关于#python#的问题,如何解决?

问题遇到的现象和发生背景

python使用pip下载wxPython时遇到错误

问题相关代码,请勿粘贴截图

Processing c:\users\25226\desktop\wxpython-4.1.1.tar.gz
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: pillow in e:\python\lib\site-packages (from wxPython==4.1.1) (9.0.1)
Requirement already satisfied: six in e:\python\lib\site-packages (from wxPython==4.1.1) (1.16.0)
Requirement already satisfied: numpy in c:\users\25226\pycharmprojects\pythonproject1\venv\lib\site-packages (from wxPython==4.1.1) (1.22.3)
Building wheels for collected packages: wxPython
Building wheel for wxPython (setup.py): started
Building wheel for wxPython (setup.py): finished with status 'error'
Running setup.py clean for wxPython
Failed to build wxPython
Installing collected packages: wxPython
Running setup.py install for wxPython: started
Running setup.py install for wxPython: finished with status 'error'

error: subprocess-exited-with-error

python setup.py bdist_wheel did not run successfully.
exit code: 1

[49 lines of output]
C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\dist.py:723: 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\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\dist.py:300: DistDeprecationWarning: use_2to3 is ignored.
warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
running bdist_wheel
running build
Will build using: "C:\Users\25226\PycharmProjects\pythonProject1\venv\Scripts\python.exe"
3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [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:\Users\25226\PycharmProjects\pythonProject1\venv\Scripts\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:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\_distutils\msvc9compiler.py", line 371, in initialize

  vc_env = query_vcvarsall(VERSION, plat_spec)

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\msvc.py", line 140, in msvc9_query_vcvarsall

  return EnvironmentInfo(arch, ver).return_env()

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\msvc.py", line 1740, in return_env

  [self.VCIncludes,

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\msvc.py", line 1282, in VCIncludes

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

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\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 (0m4.700s)
Finished command: build (0m4.700s)
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\25226\PycharmProjects\pythonProject1\venv\Scripts\python.exe" -u build.py build
Command '"C:\Users\25226\PycharmProjects\pythonProject1\venv\Scripts\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: Failed building wheel for wxPython
error: subprocess-exited-with-error

Running setup.py install for wxPython did not run successfully.
exit code: 1

[51 lines of output]
C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\dist.py:723: 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\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\dist.py:300: DistDeprecationWarning: use_2to3 is ignored.
warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
running install
C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
Will build using: "C:\Users\25226\PycharmProjects\pythonProject1\venv\Scripts\python.exe"
3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [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:\Users\25226\PycharmProjects\pythonProject1\venv\Scripts\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:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\_distutils\msvc9compiler.py", line 371, in initialize

  vc_env = query_vcvarsall(VERSION, plat_spec)

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\msvc.py", line 140, in msvc9_query_vcvarsall

  return EnvironmentInfo(arch, ver).return_env()

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\msvc.py", line 1740, in return_env

  [self.VCIncludes,

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\lib\site-packages\setuptools\msvc.py", line 1282, in VCIncludes

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

File "C:\Users\25226\PycharmProjects\pythonProject1\venv\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.750s)
Finished command: build (0.751s)
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\25226\PycharmProjects\pythonProject1\venv\Scripts\python.exe" -u build.py build
Command '"C:\Users\25226\PycharmProjects\pythonProject1\venv\Scripts\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.

运行结果及报错内容

安装失败

我的解答思路和尝试过的方法

下载了visual C++生成工具,仍然无法安装

我想要达到的结果

是你python版本的问题


可以看下python参考手册中的 python- 接下来?