Msys2: readline in two python installations

血红的双手。 提交于 2020-05-24 05:14:43

问题


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
>>>

来源:https://stackoverflow.com/questions/61390715/msys2-readline-in-two-python-installations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!