title: How to fix: "Testing pyext configuration : Could not build python extensions"
body: <p>I am trying to install wxPython but the wheel build fails. The error message is not helpful in indicating what to do or where to look to fix this. Can anyone please help me understand how to build this wheel correctly?</p>
  
  <pre><code>Machine: Linux on Power (this is not x86)
  OS: RHEL Server, 7.5 (Maipo)
  python version: Python 3.6.4
  pip3 version: pip 19.3.1
  </code></pre>
  
  <p>I noticed <a href="https://stackoverflow.com/questions/55686679/unable-to-install-wxpython-on-ubuntu-with-python3-7-using-pip3">this stack overflow post</a>, which is also not helpful because my linux release is not on the list of the ones provided.</p>
  
  <p>Following links above I tried <a href="https://wxpython.org/pages/downloads/" rel="nofollow noreferrer">wxPython download page</a> and the following <a href="https://wxpython.org/blog/2017-08-17-builds-for-linux-with-pip/" rel="nofollow noreferrer">install with pip</a> but in step 5 basically tells you "look at the log and figure it out"....not helpful.</p>
  
  <p>I tried to manually hack the wxPython package using my very limited competence and removed some dependency.....still nothing.</p>
  
  <pre><code>&lt;...&gt;
    Finished command: build_wx (1m56.907s)
    Running command: build_py
    Checking for /tmp/pip-req-build-dgnp13sp/bin/waf-2.0.8...
    "/afs/apd.pok.ibm.com/u/mfacchin/wxenvlop/bin/python3" /tmp/pip-req-build-dgnp13sp/bin/waf-2.0.8 --wx_config=/tmp/pip-req-build-dgnp13sp/build/wxbld/gtk3/wx-config --gtk3 --python="/afs/apd.pok.ibm.com/u/mfacchin/wxenvlop/bin/python3" --out=build/waf/3.6/gtk3 configure build
    Setting top to                           : /tmp/pip-req-build-dgnp13sp
    Setting out to                           : /tmp/pip-req-build-dgnp13sp/build/waf/3.6/gtk3
    Checking for 'gcc' (C compiler)          : /bin/gcc
    Checking for 'g++' (C++ compiler)        : /bin/g++
    Checking for program 'python'            : /afs/apd.pok.ibm.com/u/mfacchin/wxenvlop/bin/python3
    Checking for python version &gt;= 2.7.0     : 3.6.4
    python-config                            : /opt/xsite/cte/tools/python/3.6/bin/python3.6-config
    Asking python-config for pyext '--cflags --libs --ldflags' flags : yes
    Testing pyext configuration                                      : Could not build python extensions
    The configuration failed
    (complete log in /tmp/pip-req-build-dgnp13sp/build/waf/3.6/gtk3/config.log)
    Command '"/afs/apd.pok.ibm.com/u/mfacchin/wxenvlop/bin/python3" /tmp/pip-req-build-dgnp13sp/bin/waf-2.0.8 --wx_config=/tmp/pip-req-build-dgnp13sp/build/wxbld/gtk3/wx-config --gtk3 --python="/afs/apd.pok.ibm.com/u/mfacchin/wxenvlop/bin/python3" --out=build/waf/3.6/gtk3 configure build ' failed with exit code 1.
    Finished command: build_py (0m6.991s)
    Finished command: build (2m3.899s)
    Command '"/afs/apd.pok.ibm.com/u/mfacchin/wxenvlop/bin/python3" -u build.py build' failed with exit code 1.
    Building wheel for wxPython (setup.py): finished with status 'error'
    ERROR: Failed building wheel for wxPython
  &lt;...&gt;
  </code></pre>
  
  <p>----Update 12/2 (After Robin Dunn's feedback)
  Thank you Robin for the directives. Following is the last portion of the config.log from a different run using the build command. Also the error message is slightly different (below, following the config.log), because I had previously used the explicit wheel-build command: pip wheel -v wxPython-4.0.7.post1.tar.gz  2>&amp;1 | tee build.log. Does this log below confirm your theory regarding the Python built with the --enable-shared configure flag?</p>
  
  <pre><code>Testing pyext configuration
  ==&gt;
  
  #include &lt;Python.h&gt;
  #ifdef __cplusplus
  extern "C" {
  #endif
      void Py_Initialize(void);
      void Py_Finalize(void);
  #ifdef __cplusplus
  }
  #endif
  int main(int argc, char **argv)
  {
     (void)argc; (void)argv;
     Py_Initialize();
     Py_Finalize();
     return 0;
  }
  
  &lt;==
  [1/2] Compiling [32mbuild/waf/3.6/gtk3/.conf_check_cfc3ecfbbf37890054f6518ca7961071/test.cpp[0m
  
  ['/bin/g++', '-fPIC', '-g', '-fwrapv', '-O3', '-I../../../../../../../../../../../../../../cte/tools/python/vol2/.3.6.4-linux-ppc64le/include/python3.6m', '-I/opt/xsite/cte/tools/python/common2018/include', '-DPYTHONDIR="/usr/local/lib/python3.6/site-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python3.6/site-packages"', '-DNDEBUG', '../test.cpp', '-c', '-o/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/build/waf/3.6/gtk3/.conf_check_cfc3ecfbbf37890054f6518ca7961071/testbuild/test.cpp.1.o']
  [2/2] Linking [33mbuild/waf/3.6/gtk3/.conf_check_cfc3ecfbbf37890054f6518ca7961071/testbuild/testprog.cpython-36m-powerpc64le-linux-gnu.so[0m
  
  ['/bin/g++', '-shared', '-Xlinker', '-export-dynamic', 'test.cpp.1.o', '-o', '/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/build/waf/3.6/gtk3/.conf_check_cfc3ecfbbf37890054f6518ca7961071/testbuild/testprog.cpython-36m-powerpc64le-linux-gnu.so', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-L/afs/apd.pok.ibm.com/func/vlsi/cte/tools/python/vol2/.3.6.4-linux-ppc64le/lib/python3.6/config-3.6m-powerpc64le-linux-gnu', '-L/afs/apd.pok.ibm.com/func/vlsi/cte/tools/python/vol2/.3.6.4-linux-ppc64le/lib', '-lpython3.6m', '-lpthread', '-ldl', '-lutil', '-lm', '-lpython3.6m', '-lpthread', '-ldl', '-lutil', '-lm']
  err: /bin/ld: /afs/apd.pok.ibm.com/func/vlsi/cte/tools/python/vol2/.3.6.4-linux-ppc64le/lib/python3.6/config-3.6m-powerpc64le-linux-gnu/libpython3.6m.a(Python-ast.o): In function `obj2ast_keyword':
  /data/ubrandt/Python-3.6.4/Python/Python-ast.c:7767:(.text.unlikely+0x608): call to `_Py_keyword' lacks nop, can't restore toc; recompile with -fPIC
  /bin/ld: /afs/apd.pok.ibm.com/func/vlsi/cte/tools/python/vol2/.3.6.4-linux-ppc64le/lib/python3.6/config-3.6m-powerpc64le-linux-gnu/libpython3.6m.a(Python-ast.o): In function `obj2ast_comprehension':
  /data/ubrandt/Python-3.6.4/Python/Python-ast.c:7419:(.text.unlikely+0x9f4): call to `_Py_comprehension' lacks nop, can't restore toc; recompile with -fPIC
  /bin/ld: /afs/apd.pok.ibm.com/func/vlsi/cte/tools/python/vol2/.3.6.4-linux-ppc64le/lib/python3.6/config-3.6m-powerpc64le-linux-gnu/libpython3.6m.a(Python-ast.o): In function `obj2ast_alias':
  /data/ubrandt/Python-3.6.4/Python/Python-ast.c:7802:(.text.unlikely+0xbec): call to `_Py_alias' lacks nop, can't restore toc; recompile with -fPIC
  /bin/ld: /afs/apd.pok.ibm.com/func/vlsi/cte/tools/python/vol2/.3.6.4-linux-ppc64le/lib/python3.6/config-3.6m-powerpc64le-linux-gnu/libpython3.6m.a(Python-ast.o): In function `obj2ast_withitem':
  /data/ubrandt/Python-3.6.4/Python/Python-ast.c:7837:(.text.unlikely+0xdd4): call to `_Py_withitem' lacks nop, can't restore toc; recompile with -fPIC
  /bin/ld: final link failed: Bad value
  collect2: error: ld returned 1 exit status
  
  from /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1: Test does not build: Traceback (most recent call last):
    File "/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/bin/.waf3-2.0.8-206f2b7a89029e71942a2beb9e1bbbbd/waflib/Configure.py", line 324, in run_build
      bld.compile()
    File "/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/bin/.waf3-2.0.8-206f2b7a89029e71942a2beb9e1bbbbd/waflib/Build.py", line 176, in compile
      raise Errors.BuildError(self.producer.error)
  waflib.Errors.BuildError: Build failed
   -&gt; task in 'testprog' failed with exit status 1 (run with -v to display more information)
  
  Could not build python extensions
  from /.....: The configuration failed
  </code></pre>
  
  <p>and this is the error message that I get this new run, slightly different</p>
  
  <pre><code>msgfmt --verbose -c -o zh_TW.mo zh_TW.po
  1710 translated messages, 82 fuzzy translations, 61 untranslated messages.
  make[1]: Leaving directory `/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/ext/wxWidgets/locale'
  Setting top to                           : /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1 
  Setting out to                           : /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/build/waf/3.6/gtk3 
  Checking for 'gcc' (C compiler)          : /bin/gcc 
  Checking for 'g++' (C++ compiler)        : /bin/g++ 
  Checking for program 'python'            : /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/bin/python3 
  Checking for python version &gt;= 2.7.0     : 3.6.4 
  python-config                            : /opt/xsite/cte/tools/python/3.6/bin/python3.6-config 
  Asking python-config for pyext '--cflags --libs --ldflags' flags : yes 
  Testing pyext configuration                                      : Could not build python extensions 
  The configuration failed
  (complete log in /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/build/waf/3.6/gtk3/config.log)
  Will build using: "/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/bin/python3"
  3.6.4 (default, Feb 12 2018, 16:08:32) 
  [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
  Python's architecture is 64bit
  cfg.VERSION: 4.0.7.post1
  
  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']
  /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/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
  make --jobs=128
  Building message catalogs in /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/ext/wxWidgets/locale
  make allmo
  Finished command: build_wx (12m36.623s)
  Running command: build_py
  Checking for /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/bin/waf-2.0.8...
  "/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/bin/python3" /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/bin/waf-2.0.8 --wx_config=/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/build/wxbld/gtk3/wx-config --gtk3 --python="/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/bin/python3" --out=build/waf/3.6/gtk3 configure build 
  Command '"/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/bin/python3" /afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/bin/waf-2.0.8 --wx_config=/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/wxPython-4.0.7.post1_mf1/build/wxbld/gtk3/wx-config --gtk3 --python="/afs/apd.pok.ibm.com/func/vlsi/eclipz/sf5/usr/mfacchin/c01/python_venv/wxenv191202/bin/python3" --out=build/waf/3.6/gtk3 configure build ' failed with exit code 1.
  Finished command: build_py (2m7.118s)
  Finished command: build (14m43.742s)
  </code></pre>