easybuilders / easybuild-easyconfigs

A collection of easyconfig files that describe which software to build using which build options with EasyBuild.
https://easybuild.io
GNU General Public License v2.0
373 stars 699 forks source link

Python/ncurses: AttributeError: '_curses.window' object has no attribute 'get_wch' #10231

Open SethosII opened 4 years ago

SethosII commented 4 years ago

I'm facing an issue with Python and ncurses. When I use a ncursesw function like get_wch it's not found, but it works with the system Python:

$ ml Python/3.6.6-foss-2018b
$ ml

Currently Loaded Modules:
  1) GCCcore/7.3.0                  9) libpciaccess/0.14-GCCcore-7.3.0             17) bzip2/1.0.6-GCCcore-7.3.0
  2) ncurses/6.1-GCCcore-7.3.0     10) hwloc/1.11.10-GCCcore-7.3.0                 18) libreadline/7.0-GCCcore-7.3.0
  3) zlib/1.2.11-GCCcore-7.3.0     11) OpenMPI/3.1.1-GCC-7.3.0-2.30                19) Tcl/8.6.8-GCCcore-7.3.0
  4) binutils/2.30-GCCcore-7.3.0   12) OpenBLAS/0.3.1-GCC-7.3.0-2.30               20) SQLite/3.24.0-GCCcore-7.3.0
  5) GCC/7.3.0-2.30                13) gompi/2018b                                 21) GMP/6.1.2-GCCcore-7.3.0
  6) numactl/2.0.11-GCCcore-7.3.0  14) FFTW/3.3.8-gompi-2018b                      22) libffi/3.2.1-GCCcore-7.3.0
  7) XZ/5.2.4-GCCcore-7.3.0        15) ScaLAPACK/2.0.2-gompi-2018b-OpenBLAS-0.3.1  23) Python/3.6.6-foss-2018b
  8) libxml2/2.9.8-GCCcore-7.3.0   16) foss/2018b

$ python3 -c "import curses; curses.wrapper(lambda sc: sc.get_wch())"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/mnt/software/easybuild/18.04/software/Python/3.6.6-foss-2018b/lib/python3.6/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "<string>", line 1, in <lambda>
AttributeError: '_curses.window' object has no attribute 'get_wch'
$ ml purge
$ python3 -VV
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0]
$ python3 -c "import curses; curses.wrapper(lambda sc: sc.get_wch())"
# no error, press any key to close the window

This is on Ubuntu 18.04 with these packages installed with regards to curses:

$ dpkg -l | grep curses
ii  libncurses5:amd64                      6.1-1ubuntu1.18.04                              amd64        shared libraries for terminal handling
ii  libncurses5-dev:amd64                  6.1-1ubuntu1.18.04                              amd64        developer's libraries for ncurses
ii  libncursesw5:amd64                     6.1-1ubuntu1.18.04                              amd64        shared libraries for terminal handling (wide character support)
ii  libncursesw5-dev:amd64                 6.1-1ubuntu1.18.04                              amd64        developer's libraries for ncursesw
ii  mtr-tiny                               0.92-1                                          amd64        Full screen ncurses traceroute tool
ii  ncdu                                   1.12-1                                          amd64        ncurses disk usage viewer
ii  ncurses-base                           6.1-1ubuntu1.18.04                              all          basic terminal type definitions
ii  ncurses-bin                            6.1-1ubuntu1.18.04                              amd64        terminal-related programs and man pages
ii  ncurses-term                           6.1-1ubuntu1.18.04                              all          additional terminal type definitions
boegel commented 4 years ago

This issue is probably caused by explicitly linking Python with libncurses.a (see https://github.com/easybuilders/easybuild-easyblocks/blob/develop/easybuild/easyblocks/p/python.py#L199), rather than with libncursesw.a which is a separate ncurses library that provides "wide character" support?

Perhaps we should opt for linking with libncursesw.a if that's available, and fall back to linking with libncurses.a if it's not available?

Can you check if that would resolve the issue you're seeing @SethosII ?

SethosII commented 4 years ago

@boegel I replaced libncurses.a with libncursesw.a and the log shows it's picked up but I still get the same error when calling get_wch.