2

I am top-posting EDITs so the reader does not need to locate the current status.

This is a specific question related to the two python installations mentioned in Msys2: Maintaining two python installations

$ pacman -Sl | grep "python " | grep "installed"
mingw64 mingw-w64-x86_64-python 3.8.2-2 [installed]
msys python 3.8.2-1 [installed]


EDIT #2:

It became clear that readlines quoted below were not python packages, but for shells. As for readline for python, the files provided by each package are

$ pacman -Ql python | grep readline
python /usr/lib/python3.8/lib-dynload/readline.cpython-38-i386-msys.dll
python /usr/lib/python3.8/lib2to3/fixes/fix_xreadlines.py
python /usr/lib/python3.8/test/test_readline.py
$ pacman -Ql mingw-w64-x86_64-python | grep readline
mingw-w64-x86_64-python /mingw64/lib/python3.8/lib2to3/fixes/__pycache__/fix_xreadlines.cpython-38.opt-1.pyc
mingw-w64-x86_64-python /mingw64/lib/python3.8/lib2to3/fixes/__pycache__/fix_xreadlines.cpython-38.opt-2.pyc
mingw-w64-x86_64-python /mingw64/lib/python3.8/lib2to3/fixes/__pycache__/fix_xreadlines.cpython-38.pyc
mingw-w64-x86_64-python /mingw64/lib/python3.8/lib2to3/fixes/fix_xreadlines.py
mingw-w64-x86_64-python /mingw64/lib/python3.8/test/__pycache__/test_readline.cpython-38.opt-1.pyc
mingw-w64-x86_64-python /mingw64/lib/python3.8/test/__pycache__/test_readline.cpython-38.opt-2.pyc
mingw-w64-x86_64-python /mingw64/lib/python3.8/test/__pycache__/test_readline.cpython-38.pyc
mingw-w64-x86_64-python /mingw64/lib/python3.8/test/test_readline.py

So, Why is it that python from package mingw-w64-x86_64-python doesn't find readline (see below), and is there a way to fix this? Compare with python from package python, which has readline available.

$ python3.8         <-- This is /usr/bin/python3.8, from msys python
Python 3.8.2 (default, Apr 16 2020, 15:31:48)
[GCC 9.3.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
Reading /home/RY16205/.pythonrc
readline is in /usr/lib/python3.8/lib-dynload/readline.cpython-38-i386-msys.dll
>>>
$ /mingw64/bin/python3.8.exe        <-- From mingw64 python. Have to call it with full path, otherwise msys python is run
Python 3.8.2 (default, Apr  9 2020, 13:17:39)  [GCC 9.3.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Reading C:/Users/RY16205/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/RY16205/.pythonrc
Module readline not available.
Traceback (most recent call last):
  File "C:/Users/RY16205/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/RY16205/.pythonrc", line 42, in <module>
    del os, atexit, readline, rlcompleter, save_history, historyPath
NameError: name 'readline' is not defined
>>>


======TL;DR======
EDIT #1

A verbose output of a reinstallation is shown below. The list of files provided by each package is also given below. It is worth noting the (apparent) mismatch between the sign when importing msys readline:

readline is in /usr/lib/python3.8/lib-dynload/readline.cpython-38-i386-msys.dll

and the fact that this file is not provided by package msys readline, as listed below. Moreover, it seems to be provided by msys python,

$ pacman -Qo readline.cpython-38-i386-msys.dll
error: No package owns readline.cpython-38-i386-msys.dll
$ pkgfile.exe readline.cpython-38-i386-msys.dll
msys/python

although this further mismatch between pkgfile and pacman -Qo deserves yet another question.

Reinstallation of mingw-w64-x86_64-readline

$ pacman -S -v mingw-w64-x86_64-readline
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : mingw-w64-x86_64-readline
warning: mingw-w64-x86_64-readline-8.0.004-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) mingw-w64-x86_64-readline-8.0.004-1

Total Installed Size:  1.56 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                                                                         [###########################################################] 100% (1/1) checking package integrity                                                                       [###########################################################] 100% (1/1) loading package files                                                                            [###########################################################] 100% (1/1) checking for file conflicts                                                                      [###########################################################] 100% (1/1) checking available disk space                                                                    [###########################################################] 100% :: Processing package changes...
(1/1) reinstalling mingw-w64-x86_64-readline                                                           [###########################################################] 100% 

List of files provided by each package

$ pacman -Ql mingw-w64-x86_64-readline
mingw-w64-x86_64-readline /mingw64/
mingw-w64-x86_64-readline /mingw64/bin/
mingw-w64-x86_64-readline /mingw64/bin/libhistory8.dll
mingw-w64-x86_64-readline /mingw64/bin/libreadline8.dll
mingw-w64-x86_64-readline /mingw64/include/
mingw-w64-x86_64-readline /mingw64/include/readline/
mingw-w64-x86_64-readline /mingw64/include/readline/chardefs.h
mingw-w64-x86_64-readline /mingw64/include/readline/history.h
mingw-w64-x86_64-readline /mingw64/include/readline/keymaps.h
mingw-w64-x86_64-readline /mingw64/include/readline/readline.h
mingw-w64-x86_64-readline /mingw64/include/readline/rlconf.h
mingw-w64-x86_64-readline /mingw64/include/readline/rlstdc.h
mingw-w64-x86_64-readline /mingw64/include/readline/rltypedefs.h
mingw-w64-x86_64-readline /mingw64/include/readline/tilde.h
mingw-w64-x86_64-readline /mingw64/lib/
mingw-w64-x86_64-readline /mingw64/lib/libhistory.a
mingw-w64-x86_64-readline /mingw64/lib/libhistory.dll.a
mingw-w64-x86_64-readline /mingw64/lib/libreadline.a
mingw-w64-x86_64-readline /mingw64/lib/libreadline.dll.a
mingw-w64-x86_64-readline /mingw64/lib/pkgconfig/
mingw-w64-x86_64-readline /mingw64/lib/pkgconfig/readline.pc
mingw-w64-x86_64-readline /mingw64/share/
mingw-w64-x86_64-readline /mingw64/share/doc/
mingw-w64-x86_64-readline /mingw64/share/doc/readline/
mingw-w64-x86_64-readline /mingw64/share/doc/readline/CHANGES
mingw-w64-x86_64-readline /mingw64/share/doc/readline/INSTALL
mingw-w64-x86_64-readline /mingw64/share/doc/readline/README
mingw-w64-x86_64-readline /mingw64/share/info/
mingw-w64-x86_64-readline /mingw64/share/info/history.info.gz
mingw-w64-x86_64-readline /mingw64/share/info/readline.info.gz
mingw-w64-x86_64-readline /mingw64/share/info/rluserman.info.gz
mingw-w64-x86_64-readline /mingw64/share/man/
mingw-w64-x86_64-readline /mingw64/share/man/man3/
mingw-w64-x86_64-readline /mingw64/share/man/man3/history.3.gz
mingw-w64-x86_64-readline /mingw64/share/man/man3/readline.3.gz
mingw-w64-x86_64-readline /mingw64/share/readline/
mingw-w64-x86_64-readline /mingw64/share/readline/excallback.c
mingw-w64-x86_64-readline /mingw64/share/readline/fileman.c
mingw-w64-x86_64-readline /mingw64/share/readline/hist_erasedups.c
mingw-w64-x86_64-readline /mingw64/share/readline/hist_purgecmd.c
mingw-w64-x86_64-readline /mingw64/share/readline/histexamp.c
mingw-w64-x86_64-readline /mingw64/share/readline/manexamp.c
mingw-w64-x86_64-readline /mingw64/share/readline/rl-callbacktest.c
mingw-w64-x86_64-readline /mingw64/share/readline/rl-fgets.c
mingw-w64-x86_64-readline /mingw64/share/readline/rl.c
mingw-w64-x86_64-readline /mingw64/share/readline/rlbasic.c
mingw-w64-x86_64-readline /mingw64/share/readline/rlcat.c
mingw-w64-x86_64-readline /mingw64/share/readline/rlevent.c
mingw-w64-x86_64-readline /mingw64/share/readline/rlkeymaps.c
mingw-w64-x86_64-readline /mingw64/share/readline/rlptytest.c
mingw-w64-x86_64-readline /mingw64/share/readline/rltest.c
mingw-w64-x86_64-readline /mingw64/share/readline/rlversion.c

$ pacman -Ql libreadline
libreadline /usr/
libreadline /usr/bin/
libreadline /usr/bin/msys-history8.dll
libreadline /usr/bin/msys-readline8.dll
libreadline /usr/share/
libreadline /usr/share/doc/
libreadline /usr/share/doc/readline/
libreadline /usr/share/doc/readline/CHANGES
libreadline /usr/share/doc/readline/INSTALL
libreadline /usr/share/doc/readline/README
libreadline /usr/share/info/
libreadline /usr/share/info/history.info.gz
libreadline /usr/share/info/readline.info.gz
libreadline /usr/share/info/rluserman.info.gz
libreadline /usr/share/man/
libreadline /usr/share/man/man3/
libreadline /usr/share/man/man3/history.3.gz
libreadline /usr/share/man/man3/readline.3.gz
libreadline /usr/share/readline/
libreadline /usr/share/readline/excallback.c
libreadline /usr/share/readline/fileman.c
libreadline /usr/share/readline/hist_erasedups.c
libreadline /usr/share/readline/hist_purgecmd.c
libreadline /usr/share/readline/histexamp.c
libreadline /usr/share/readline/manexamp.c
libreadline /usr/share/readline/rl-callbacktest.c
libreadline /usr/share/readline/rl-fgets.c
libreadline /usr/share/readline/rl.c
libreadline /usr/share/readline/rlbasic.c
libreadline /usr/share/readline/rlcat.c
libreadline /usr/share/readline/rlevent.c
libreadline /usr/share/readline/rlkeymaps.c
libreadline /usr/share/readline/rlptytest.c
libreadline /usr/share/readline/rltest.c
libreadline /usr/share/readline/rlversion.c


OP

I seem to have readline installed in both pythons, but in one case it is not found. I guess there should be no problem in having readline in both.

What is the problem, and how can I solve it? I would rather keep both pythons, for the time being. I am not sure why I ended up having both, so I suspect they were (at least at one point) both needed for some reason.

PS: These two pythons are likely upgrades from the main characters of [this "play"][1], python 3.8 (3.8.1 before) upgraded to mingw-w64-x86_64-python 3.8.2-2 and python 3.7 upgraded to python 3.8.2-1.

Supporting code/info

$ pacman -Sl | grep readline
mingw32 mingw-w64-i686-python-pyreadline 2.1-1
mingw32 mingw-w64-i686-readline 8.0.004-1
mingw64 mingw-w64-x86_64-python-pyreadline 2.1-1
mingw64 mingw-w64-x86_64-readline 8.0.004-1 [installed]
msys libreadline 8.0.004-1 [installed]

I import readline in .pythonrc (which is the same for both), and I guess each python should be able to find its readline. But mingw64 python does not find its readline, while msys python finds its readline.

$ python3.8         <-- This is /usr/bin/python3.8, from msys python
Python 3.8.2 (default, Apr 16 2020, 15:31:48)
[GCC 9.3.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
Reading /home/RY16205/.pythonrc
readline is in /usr/lib/python3.8/lib-dynload/readline.cpython-38-i386-msys.dll
>>>
$ /mingw64/bin/python3.8.exe        <-- From mingw64 python. Have to call it with full path, otherwise msys python is run
Python 3.8.2 (default, Apr  9 2020, 13:17:39)  [GCC 9.3.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Reading C:/Users/RY16205/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/RY16205/.pythonrc
Module readline not available.
Traceback (most recent call last):
  File "C:/Users/RY16205/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/RY16205/.pythonrc", line 42, in <module>
    del os, atexit, readline, rlcompleter, save_history, historyPath
NameError: name 'readline' is not defined
>>>
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Does it help to reinstall the `mingw-w64-x86_64-readline` package? It seems that this package is not effective (at least not from the perspective of Python). Is there a way to check what installing that package actually does? E.g. installing in some verbose mode, to see where files get copied etc.? – a_guest Apr 24 '20 at 12:08
  • @a_guest - No, it did not help. Yes, there is a way to check what the installation does. Please see edit at the bottom. – sancho.s ReinstateMonicaCellio Apr 24 '20 at 13:23
  • Looks like `mingw-w64-x86_64-readline` has nothing to do with Python, it's just general purpose functionality used by other packages. Usually `readline` ships with Pyhon itself (as you have observed for he msys version) so either your mingw64 version is very minimal or it's broken (maybe those are the same). You could try to reinstall that version of Python. If it doesn't help maybe you can create a module `readline.py` and `import libreadline8`. At least you can check whether you can `/mingw64/bin/libreadline8.dll` (most likely not, since it doesn't seem to be created for usage with Python). – a_guest Apr 24 '20 at 13:32
  • @a_guest - You are right!! Silly me... Those `readline`s are for shell environments... – sancho.s ReinstateMonicaCellio Apr 24 '20 at 13:51
  • @a_guest - Please see EDIT at the top. I reinstalled, it didn't help. I am surprised that `mingw-w64-x86_64-python` does not have `readline`... – sancho.s ReinstateMonicaCellio Apr 24 '20 at 14:23
  • I don't know for sure but my assumption is that mingw-python is built for Windows, i.e. compiled with mingw compilers with Microsoft C runtimes. Python installations on Windows don't have the `readline` module. Here you should install `pyreadline`. However since you run the whole thing in msys you indeed need `readline`. So it seems that the mingw-python is not compatible with msys. – a_guest Apr 24 '20 at 14:54

0 Answers0