背景

因为robotframework-ride依赖wxPython第三方包,安装robotframework-ride失败,报如下错误信息:

Building wheels for collected packages: wxpython
  Building wheel for wxpython (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for wxpython (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [85 lines of output]
      running bdist_wheel
      running build
      build.py:44: DeprecationWarning: dep_util is Deprecated. Use functions from setuptools instead.
        from distutils.dep_util import newer, newer_group
      Will build using: "/home/youngyoung/py-env/bin/python3"
      3.8.10 (default, Jun 14 2025, 14:13:57)
      [GCC 8.5.0 20210514 (Red Hat 8.5.0-4)]
      Python's architecture is 64bit
      cfg.VERSION: 4.2.2
      
      Running command: build
      Running command: build_wx
      wxWidgets build options: ['--wxpython', '--unicode', '--gtk3']
      Configure options: ['--enable-unicode', '--with-gtk=3', '--enable-sound', '--enable-graphics_ctx', '--enable-display', '--enable-geometry', '--enable-debug_flag', '--enable-optimise', '--disable-debugreport', '--enable-uiactionsim', '--enable-autoidman', '--with-sdl']
      /tmp/pip-install-qmi_1gbp/wxpython_aa583256dcfc45c586a464f0a4f927f5/ext/wxWidgets/configure --enable-unicode --with-gtk=3 --enable-sound --enable-graphics_ctx --enable-display --enable-geometry --enable-debug_flag --enable-optimise --disable-debugreport --enable-uiactionsim --enable-autoidman --with-sdl
      checking build system type... x86_64-pc-linux-gnu
      checking host system type... x86_64-pc-linux-gnu
      checking for toolkit... gtk
      checking for gcc... gcc
      checking whether the C compiler works... yes
      checking for C compiler default output file name... a.out
      checking for suffix of executables...
      checking whether we are cross compiling... no
      checking for suffix of object files... o
      checking whether we are using the GNU C compiler... yes
      checking whether gcc accepts -g... yes
      checking for gcc option to accept ISO C89... none needed
      checking whether we are using the Intel C compiler... no
      checking how to run the C preprocessor... gcc -E
      checking for grep that handles long lines and -e... /usr/bin/grep
      checking for egrep... /usr/bin/grep -E
      checking whether gcc needs -traditional... no
      checking for g++... no
      checking for c++... no
      checking for gpp... no
      checking for aCC... no
      checking for CC... no
      checking for cxx... no
      checking for cc++... no
      checking for cl.exe... no
      checking for FCC... no
      checking for KCC... no
      checking for RCC... no
      checking for xlC_r... no
      checking for xlC... no
      checking whether we are using the GNU C++ compiler... no
      checking whether g++ accepts -g... no
      checking whether we are using the Intel C++ compiler... no
      checking whether we are using the Sun C++ compiler... no
      configure: error: C++ compiler is needed to build wxWidgets
      Error running configure
      ERROR: failed building wxWidgets
      Traceback (most recent call last):
        File "build.py", line 1588, in cmd_build_wx
          wxbuild.main(wxDir(), build_options)
        File "/tmp/pip-install-qmi_1gbp/wxpython_aa583256dcfc45c586a464f0a4f927f5/buildtools/build_wxwidgets.py", line 379, in main
          exitIfError(wxBuilder.configure(dir=wxRootDir, options=configure_opts),
        File "/tmp/pip-install-qmi_1gbp/wxpython_aa583256dcfc45c586a464f0a4f927f5/buildtools/build_wxwidgets.py", line 72, in exitIfError
          raise builder.BuildError(msg)
      buildtools.builder.BuildError: Error running configure
      Finished command: build_wx (0.559s)
      Finished command: build (0.559s)
      /home/youngyoung/py-env/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py:280: _IncompatibleBdistWheel: wheel.bdist_wheel is deprecated, please import it from setuptools
      !!
      
              ********************************************************************************
              Ensure that any custom bdist_wheel implementation is a subclass of
              setuptools.command.bdist_wheel.bdist_wheel.
      
              By 2025-Oct-15, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.
      
              See https://github.com/pypa/wheel/pull/631 for details.
              ********************************************************************************
      
      !!
        return _build_backend().build_wheel(
      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.
      
      "/home/youngyoung/py-env/bin/python3" -u build.py build
      Command '"/home/youngyoung/py-env/bin/python3" -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
Failed to build wxpython
ERROR: Failed to build installable wheels for some pyproject.toml based projects (wxpython)
(atp-env) [youngyoung@localhost ~]$

分析

当尝试安装wxPython时,由于缺少C++编译器报错,因为它需要编译wxWidgets(因为wxPython使用底层的C++库)

解决方案

yum groupinstall "Development Tools"
yum install gtk3 gtk3-devel python3-devel

说明

报错中的关键error信息:

configure: error: C++ compiler is needed to build wxWidgets
      Error running configure
      ERROR: failed building wxWidgets

Development Tools工具包将会安装GCC/G++和一些其他的基本编译工具 

  asciidoc-8.6.10-0.5.20180627gitf7c2274.el8.noarch    boost-filesystem-1.66.0-10.el8.x86_64                         boost-timer-1.66.0-10.el8.x86_64                                    
  byacc-1.9.20170709-4.el8.x86_64                      copy-jdk-configs-4.0-2.el8.noarch                             ctags-5.8-22.el8.x86_64                                             
  diffstat-1.61-7.el8.x86_64                           docbook-dtds-1.0-69.el8.noarch                                docbook-style-xsl-1.79.2-9.el8.noarch                               
  dyninst-11.0.0-3.el8.x86_64                          elfutils-debuginfod-client-devel-0.185-1.el8.x86_64           elfutils-devel-0.185-1.el8.x86_64                                   
  gcc-c++-8.5.0-4.el8_5.x86_64                         gcc-gdb-plugin-8.5.0-4.el8_5.x86_64                           gdb-8.2-16.el8.x86_64                                               
  gettext-common-devel-0.19.8.1-17.el8.noarch          gettext-devel-0.19.8.1-17.el8.x86_64                          git-2.27.0-1.el8.x86_64                                             
  git-core-2.27.0-1.el8.x86_64                         git-core-doc-2.27.0-1.el8.noarch                              graphviz-2.40.1-43.el8.x86_64                                       
  intltool-0.51.0-11.el8.noarch                        java-1.8.0-openjdk-headless-1:1.8.0.312.b07-2.el8_5.x86_64    javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch   
  jna-4.5.1-5.el8.x86_64                               kernel-devel-4.18.0-348.7.1.el8_5.x86_64                      libXaw-1.0.13-10.el8.x86_64                                         
  libstdc++-devel-8.5.0-4.el8_5.x86_64                 libzstd-devel-1.4.4-1.el8.x86_64                              lksctp-tools-1.0.18-3.el8.x86_64                                    
  ltrace-0.7.91-28.el8.x86_64                          nss-tools-3.67.0-6.el8_4.x86_64                               patchutils-0.3.4-10.el8.x86_64                                      
  perl-Error-1:0.17025-2.el8.noarch                    perl-Fedora-VSP-0.001-9.el8.noarch                            perl-Git-2.27.0-1.el8.noarch                                        
  perl-Sys-Syslog-0.35-397.el8.x86_64                  perl-TermReadKey-2.37-7.el8.x86_64                            perl-XML-Parser-2.44-11.el8.x86_64                                  
  perl-generators-1.10-9.el8.noarch                    pesign-0.112-25.el8.x86_64                                    rpm-sign-4.14.3-19.el8.x86_64                                       
  sgml-common-0.6.3-50.el8.noarch                      source-highlight-3.1.8-17.el8.x86_64                          systemtap-4.5-3.el8.x86_64                                          
  systemtap-client-4.5-3.el8.x86_64                    systemtap-devel-4.5-3.el8.x86_64                              systemtap-runtime-4.5-3.el8.x86_64                                  
  tbb-2018.2-9.el8.x86_64                              tzdata-java-2021e-1.el8.noarch                                valgrind-1:3.17.0-5.el8.x86_64                                      
  valgrind-devel-1:3.17.0-5.el8.x86_64                 xorg-x11-fonts-ISO8859-1-100dpi-7.5-19.el8.noarch

wxPython编译的时候需要GTK3 开发包

Logo

火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。

更多推荐