目前python版本为3.11.2 用pip后 Using cached wxPython-4.2.0.tar.gz (71.0 MB)
PS C:\Users\admin> pip install wxpython
Collecting wxpython
Using cached wxPython-4.2.0.tar.gz (71.0 MB)
Preparing metadata (setup.py) ... done
Collecting pillow
Downloading Pillow-9.5.0-cp311-cp311-win_amd64.whl (2.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 MB 970.3 kB/s eta 0:00:00
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting numpy
Downloading numpy-1.24.2-cp311-cp311-win_amd64.whl (14.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.8/14.8 MB 69.0 kB/s eta 0:00:00
Installing collected packages: six, pillow, numpy, wxpython
DEPRECATION: wxpython is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not
installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
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
╰─> [49 lines of output]
D:\python\Lib\site-packages\setuptools\dist.py:788: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
warnings.warn(
D:\python\Lib\site-packages\setuptools\config\setupcfg.py:516: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
warnings.warn(msg, warning_class)
D:\python\Lib\site-packages\setuptools\dist.py:328: DistDeprecationWarning: use_2to3 is ignored.
warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
running install
D:\python\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
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.
"D:\python\python.exe" -u build.py build
Will build using: "D:\python\python.exe"
3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]
Python's architecture is 64bit
cfg.VERSION: 4.2.0
Running command: build
Running command: build_wx
Command '"D:\python\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('x64', 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 "" , line 1, in
File "D:\python\Lib\site-packages\setuptools\msvc.py", line 1103, in __init__
self.si = SystemInfo(self.ri, vc_ver)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\site-packages\setuptools\msvc.py", line 579, in __init__
vc_ver or self._find_latest_available_vs_ver())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\site-packages\setuptools\msvc.py", line 593, in _find_latest_available_vs_ver
raise distutils.errors.DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: No Microsoft Visual C++ version found
Finished command: build_wx (0.703s)
Finished command: build (0.703s)
Command '"D:\python\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.
这种情况应该怎么办?
根据错误信息,这个问题可能与 Microsoft Visual C++ 缺失有关。请按照以下步骤解决:
安装 Microsoft Visual C++ Build Tools:
访问 https://visualstudio.microsoft.com/visual-cpp-build-tools/ 并下载最新版本的 Microsoft Visual C++ Build Tools。
安装 wxWidgets:
下载 wxWidgets,选择您的平台(例如 Windows)和目标体系结构(例如 64 位):
https://www.wxwidgets.org/downloads/
重新运行 pip 安装命令:
运行以下命令以安装 wxpython:
pip install wxpython
如果仍然无法安装,请尝试添加 --use-pep517 选项以启用新的构建系统:
pip install wxpython --use-pep517
pip install wxPython
可能会出现些问题,如果最后提示是
WARNING: You are using pip version 19.2.3, however version 22.1 is available.
You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.
意思是:警告:您使用的是 pip 版本 19.2.3,但版本 22.1 可用。
您应该考虑通过“python -m pip install --upgrade pip”命令进行升级。
这样的话只需要再输入命令
python -m pip install --upgrade pip
升级完成,也可再检查一次
pip install wxPython
要求已经满足:wxPython in c:python 3.9.0libsite-packages (4.1.1)
要求已经满足:numpy in c:python 3.9.0libsite-packages (来自 wxPython) (1.22.3)
要求已经满足:pillow in c:python 3.9.0libsite-packages (来自 wxPython) (9.1.0)
要求已经满足:c:python 3.9.0libsite-packages 中有六个(来自 wxPython) (1.16.0)
这里提示就表明wxPython模块已经满足我们的使用要求
最后再测试下能否导入成功
python
import wx
无报错,表示可以使用了,恭喜你终于安装完成了!!!!