mike-fabian / ibus-typing-booster

ibus-typing-booster is a completion input method for faster typing
https://mike-fabian.github.io/ibus-typing-booster/
Other
232 stars 16 forks source link

[BUG] ibus-typing-booster does not start #527

Closed psads-git closed 3 months ago

psads-git commented 3 months ago

Today, dnf updated the following packages:

Packages Altered:
    Upgrade  kaccounts-integration-qt5-24.08.0-1.fc40.x86_64 @updates
    Upgraded kaccounts-integration-qt5-24.05.2-1.fc40.x86_64 @@System
    Upgrade  kaccounts-integration-qt6-24.08.0-1.fc40.x86_64 @updates
    Upgraded kaccounts-integration-qt6-24.05.2-1.fc40.x86_64 @@System
    Upgrade  kaccounts-providers-24.08.0-1.fc40.x86_64       @updates
    Upgraded kaccounts-providers-24.05.2-1.fc40.x86_64       @@System
    Upgrade  kdegraphics-mobipocket-24.08.0-1.fc40.x86_64    @updates
    Upgraded kdegraphics-mobipocket-24.05.2-1.fc40.x86_64    @@System
    Upgrade  kio-extras-24.08.0-1.fc40.x86_64                @updates
    Upgraded kio-extras-24.05.2-1.fc40.x86_64                @@System
    Upgrade  kmag-24.08.0-1.fc40.x86_64                      @updates
    Upgraded kmag-24.05.2-1.fc40.x86_64                      @@System
    Upgrade  libkexiv2-qt5-24.08.0-1.fc40.x86_64             @updates
    Upgraded libkexiv2-qt5-24.05.2-1.fc40.x86_64             @@System
    Upgrade  libkexiv2-qt6-24.08.0-1.fc40.x86_64             @updates
    Upgraded libkexiv2-qt6-24.05.2-1.fc40.x86_64             @@System
    Upgrade  okular-24.08.0-1.fc40.x86_64                    @updates
    Upgraded okular-24.05.2-1.fc40.x86_64                    @@System
    Upgrade  okular-libs-24.08.0-1.fc40.x86_64               @updates
    Upgraded okular-libs-24.05.2-1.fc40.x86_64               @@System
    Upgrade  okular-part-24.08.0-1.fc40.x86_64               @updates
    Upgraded okular-part-24.05.2-1.fc40.x86_64               @@System
    Upgrade  python3-google-auth-1:2.34.0-1.fc40.noarch      @updates
    Upgraded python3-google-auth-1:2.33.0-1.fc40.noarch      @@System
    Upgrade  python3.11-3.11.9-5.fc40.x86_64                 @updates
    Upgraded python3.11-3.11.9-2.fc40.x86_64                 @@System
    Upgrade  python3.11-libs-3.11.9-5.fc40.x86_64            @updates
    Upgraded python3.11-libs-3.11.9-2.fc40.x86_64            @@System
    Upgrade  python3.11-tkinter-3.11.9-5.fc40.x86_64         @updates
    Upgraded python3.11-tkinter-3.11.9-2.fc40.x86_64         @@System
    Upgrade  signon-kwallet-extension-24.08.0-1.fc40.x86_64  @updates
    Upgraded signon-kwallet-extension-24.05.2-1.fc40.x86_64  @@System

And now I cannot start ibus-typing-booster even after:

ibus restart

Moreover, when I try to switch from the Portuguese keyboard to ibus-typying-booster on the task bar (XFCE desktop), nothing happens and the Portuguese keyboard remains active.

Could you please help me, Mike?

mike-fabian commented 3 months ago

I am trying to reproduce it. While I am doing that, ist here anything suspicious in the log file?

If you do

tail -F ~/.local/share/ibus-typing-booster/debug.log

in some termianl and then ibus restart, do any suspicious messages appear in the terminal tracking the log file?

You can also attach the log file here.

psads-git commented 3 months ago

Thanks, Mike! I got the following, which does not change after ibus restart:

$ tail -F ~/.local/share/ibus-typing-booster/debug.log
2024-08-24 16:17:07,547 itb_active_window.py line 326 get_active_window DEBUG: Got active window from xprop: ('xfce4-terminal', 'Terminal - x@fedora:~')
2024-08-24 16:17:40,429 hunspell_table.py line 2592 _update_ui_empty_input DEBUG: entering function
2024-08-24 16:17:40,447 itb_active_window.py line 326 get_active_window DEBUG: Got active window from xprop: ('xfce4-terminal', 'Terminal - x@fedora:~')
2024-08-24 16:17:40,450 hunspell_table.py line 2592 _update_ui_empty_input DEBUG: entering function
2024-08-24 16:17:40,459 itb_active_window.py line 326 get_active_window DEBUG: Got active window from xprop: ('xfce4-terminal', 'Terminal - x@fedora:~')
2024-08-24 16:17:40,717 hunspell_table.py line 2592 _update_ui_empty_input DEBUG: entering function
2024-08-24 16:17:40,731 itb_active_window.py line 326 get_active_window DEBUG: Got active window from xprop: ('xfce4-terminal', 'Terminal - x@fedora:~')
2024-08-24 16:17:41,682 hunspell_table.py line 2592 _update_ui_empty_input DEBUG: entering function
2024-08-24 16:17:41,706 itb_active_window.py line 326 get_active_window DEBUG: Got active window from xprop: ('xfce4-terminal', 'Terminal - x@fedora:~')
2024-08-24 16:17:41,768 hunspell_table.py line 2592 _update_ui_empty_input DEBUG: entering function
mike-fabian commented 3 months ago

What version of typing booster do you have currently installed? I just did a sudo dnf update on a Fedora 40 test machine in qemu and I after that I have the latest release installed:

ibus-typing-booster-2.25.14-1.fc40.noarch

and everything works fine for me using the XFCE desktop.

I did not have any python3.11-* packages installed, only the python3-3.12* packages. But as you have some python3.11 compatibility packages installed and dnf upgraded some of them:

    Upgrade  python3.11-3.11.9-5.fc40.x86_64                 @updates
    Upgraded python3.11-3.11.9-2.fc40.x86_64                 @@System
    Upgrade  python3.11-libs-3.11.9-5.fc40.x86_64            @updates
    Upgraded python3.11-libs-3.11.9-2.fc40.x86_64            @@System
    Upgrade  python3.11-tkinter-3.11.9-5.fc40.x86_64         @updates
    Upgraded python3.11-tkinter-3.11.9-2.fc40.x86_64         @@System

I installed these as well. I didn't think it would make a difference and it did not make a difference for me.

Now I have python3 and python3.11 packages installed:

mfabian@f40:~$ rpm -qa | grep  '^python3.11-'
python3.11-tkinter-3.11.9-5.fc40.x86_64
python3.11-3.11.9-5.fc40.x86_64
python3.11-libs-3.11.9-5.fc40.x86_64
mfabian@f40:~$ rpm -qa | grep  '^python3-.*3.12'
python3-libs-3.12.4-1.fc40.x86_64
python3-tkinter-3.12.4-1.fc40.x86_64
python3-3.12.4-1.fc40.x86_64
python3-devel-3.12.4-1.fc40.x86_64
mfabian@f40:~$ 

But ibus-typing-booster still works just fine in XFCE.

mike-fabian commented 3 months ago

Thanks, Mike! I got the following, which does not change after ibus restart:

What do you mean by "does not change”? No new output appears there? 2024-08-24 16:17:41,768 is from yesterday, so you don't get any new messages from today?

psads-git commented 3 months ago

Yes, no messages today -- and I have done

ibus restart 

several times.

mike-fabian commented 3 months ago

If you had typing-booster selected in the panel while doing ibus restart, the new messages should appear immediately. If you had something else selected while doing ibus restart, new messages should appear when you switch in the panel to ibus-typing-booster.

psads-git commented 3 months ago

My setup:

$ rpm -qa | grep  '^python3.11-'
python3.11-libs-3.11.9-5.fc40.x86_64
python3.11-3.11.9-5.fc40.x86_64
python3.11-tkinter-3.11.9-5.fc40.x86_64
$

and

$ rpm -qa ibus-typing-booster
ibus-typing-booster-2.25.14-1.fc40.noarch
$
mike-fabian commented 3 months ago

Can you see ibus-typing-booster in the process list? You can check like this:

mfabian@f40:~$ ps aux | grep booster
mfabian     5384  0.1  2.4 714400 99968 ?        Sl   21:04   0:01 /usr/bin/python3 /usr/share/ibus-typing-booster/engine/mai
n.py --ibus
mfabian     5686  0.0  0.0 227788  2160 pts/0    S+   21:25   0:00 grep --color=auto booster
mfabian@f40:~$ 
psads-git commented 3 months ago

Got the following:

$ ps aux | grep booster
x          24879  0.0  0.0 227792  2060 pts/2    S+   20:26   0:00 grep --color=auto booster
$ 

I guess ibus-typing-booster does not start!

mike-fabian commented 3 months ago

My setup:

$ rpm -qa | grep  '^python3.11-'
python3.11-libs-3.11.9-5.fc40.x86_64
python3.11-3.11.9-5.fc40.x86_64
python3.11-tkinter-3.11.9-5.fc40.x86_64
$

Do you also have the Python3-3.12 packages?:

mfabian@f40:~$ rpm -qa | grep  '^python3-.*3.12'
python3-libs-3.12.4-1.fc40.x86_64
python3-tkinter-3.12.4-1.fc40.x86_64
python3-3.12.4-1.fc40.x86_64
python3-devel-3.12.4-1.fc40.x86_64
mfabian@f40:~$
$ rpm -qa ibus-typing-booster
ibus-typing-booster-2.25.14-1.fc40.noarch
$

OK!

psads-git commented 3 months ago

If you had typing-booster selected in the panel while doing ibus restart, the new messages should appear immediately. If you had something else selected while doing ibus restart, new messages should appear when you switch in the panel to ibus-typing-booster.

The point is: ibus-typing-booster cannot simply be selected in the panel!

https://github.com/user-attachments/assets/0c0c5a58-a67e-4172-9609-ad6e59ffb78f

mike-fabian commented 3 months ago

If you type this in some terminal:

/usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py 

Do you get a new message in the log file? You should get a

2024-08-25 21:35:05,567 main.py line 330 main INFO: ********** STARTING **********
psads-git commented 3 months ago

Got the following:

$ /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py 
<frozen importlib._bootstrap>:488: RuntimeWarning: Your system is avx2 capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
pygame 2.6.0 (SDL 2.30.3, Python 3.12.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
/usr/lib64/python3.12/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.0.1)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "/usr/share/ibus-typing-booster/engine/main.py", line 132, in <module>
    import factory
  File "/usr/share/ibus-typing-booster/engine/factory.py", line 37, in <module>
    import hunspell_table
  File "/usr/share/ibus-typing-booster/engine/hunspell_table.py", line 60, in <module>
    import itb_nltk
  File "/usr/share/ibus-typing-booster/engine/itb_nltk.py", line 37, in <module>
    import nltk # type: ignore
    ^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/nltk/__init__.py", line 133, in <module>
    from nltk.collocations import *
  File "/usr/lib/python3.12/site-packages/nltk/collocations.py", line 36, in <module>
    from nltk.metrics import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/__init__.py", line 18, in <module>
    from nltk.metrics.association import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/association.py", line 26, in <module>
    from scipy.stats import fisher_exact
  File "/usr/lib64/python3.12/site-packages/scipy/stats/__init__.py", line 608, in <module>
    from ._stats_py import *
  File "/usr/lib64/python3.12/site-packages/scipy/stats/_stats_py.py", line 39, in <module>
    from scipy.spatial.distance import cdist
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/__init__.py", line 110, in <module>
    from ._kdtree import *
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/_kdtree.py", line 4, in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
  File "_ckdtree.pyx", line 1, in init scipy.spatial._ckdtree
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
$
psads-git commented 3 months ago

Moreover,

tail -F ~/.local/share/ibus-typing-booster/debug.log

still returns logs only from yesterday.

mike-fabian commented 3 months ago

Got the following:

$ /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py 
<frozen importlib._bootstrap>:488: RuntimeWarning: Your system is avx2 capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
pygame 2.6.0 (SDL 2.30.3, Python 3.12.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
/usr/lib64/python3.12/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.0.1)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "/usr/share/ibus-typing-booster/engine/main.py", line 132, in <module>
    import factory
  File "/usr/share/ibus-typing-booster/engine/factory.py", line 37, in <module>
    import hunspell_table
  File "/usr/share/ibus-typing-booster/engine/hunspell_table.py", line 60, in <module>
    import itb_nltk
  File "/usr/share/ibus-typing-booster/engine/itb_nltk.py", line 37, in <module>
    import nltk # type: ignore
    ^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/nltk/__init__.py", line 133, in <module>
    from nltk.collocations import *
  File "/usr/lib/python3.12/site-packages/nltk/collocations.py", line 36, in <module>
    from nltk.metrics import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/__init__.py", line 18, in <module>
    from nltk.metrics.association import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/association.py", line 26, in <module>
    from scipy.stats import fisher_exact
  File "/usr/lib64/python3.12/site-packages/scipy/stats/__init__.py", line 608, in <module>
    from ._stats_py import *
  File "/usr/lib64/python3.12/site-packages/scipy/stats/_stats_py.py", line 39, in <module>
    from scipy.spatial.distance import cdist
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/__init__.py", line 110, in <module>
    from ._kdtree import *
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/_kdtree.py", line 4, in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
  File "_ckdtree.pyx", line 1, in init scipy.spatial._ckdtree
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
$

That is helpful! That is something I can investigate ...

mike-fabian commented 3 months ago

Hm, I did not have python3-nltk installed, but even after installing it on the test machine with

sudo dnf install  python3-nltk

it still works for me, I do not get an error from import nltk.

mike-fabian commented 3 months ago

I get this:

mfabian@f40:~$ /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py 
LookupError: 
**********************************************************************
  Resource wordnet not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('wordnet')

  For more information see: https://www.nltk.org/data.html

  Attempted to load corpora/wordnet

  Searched in:
    - '/home/mfabian/nltk_data'
    - '/usr/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************

But that is only because I did not install the corpus yet, so the nltk feature won't work until I install the corpus, but nevertheless ibus-typing-booster starts up fine for me and works normally (without the nltk feature of course).

mike-fabian commented 3 months ago

If you do this:

mfabian@f40:~$ python3
Python 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk 
>>> 

I.e. type python3 on the command line and then at the >>> prompt type import nltk.

What do you get?

For me it works, I just get the next >>> prompt.

I guess you already get an error there.

psads-git commented 3 months ago

Yes, Mike:

$ python3
Python 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
/usr/lib64/python3.12/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.0.1)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/nltk/__init__.py", line 133, in <module>
    from nltk.collocations import *
  File "/usr/lib/python3.12/site-packages/nltk/collocations.py", line 36, in <module>
    from nltk.metrics import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/__init__.py", line 18, in <module>
    from nltk.metrics.association import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/association.py", line 26, in <module>
    from scipy.stats import fisher_exact
  File "/usr/lib64/python3.12/site-packages/scipy/stats/__init__.py", line 608, in <module>
    from ._stats_py import *
  File "/usr/lib64/python3.12/site-packages/scipy/stats/_stats_py.py", line 39, in <module>
    from scipy.spatial.distance import cdist
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/__init__.py", line 110, in <module>
    from ._kdtree import *
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/_kdtree.py", line 4, in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
  File "_ckdtree.pyx", line 1, in init scipy.spatial._ckdtree
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
>>> 

I am going to reinstall ntlk.

psads-git commented 3 months ago

That is fixed now, Mike: thanks!

I had just removed numpy 2.0.1 and, afterwards, the problem was fixed.

mike-fabian commented 3 months ago

I tried to catch errors when loading nltk. If something goes wrong when trying to load nltk, then just ignore nltk and continue without that feature.

Near the top of the file /usr/share/ibus-typing-booster/engine/hunspell_table.py there is:

IMPORT_ITB_NLTK_SUCCESSFUL = False
try:
    import itb_nltk
    IMPORT_ITB_NLTK_SUCCESSFUL = True
except (ImportError, LookupError):
    IMPORT_ITB_NLTK_SUCCESSFUL = False

You see that I catch only ImportError and LookupError there. But in your case you got ValueError.

I guess if you just change the line

except (ImportError, LookupError):

to

except (ImportError, LookupError, ValueError):

then that error when attempting to load nltk will be ignored as well and ibus-typing-booster will continue without that feature.

Can you edit /usr/share/ibus-typing-booster/engine/hunspell_table.py and change only that line and try again?

mike-fabian commented 3 months ago

That is fixed now, Mike: thanks!

I had just removed numpy 2.0.1 and, afterwards, the problem was fixed.

You don't need numpy 2.0.1?

Do you have any other versions of numpy?

Does

$ python3
Python 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk

work now after removing numpy 2.0.1?

psads-git commented 3 months ago

The problem, Mike, was that there was an incompatibility between nltk and numpy 2.0.1. After

pip uninstall numpy

ibus-typing-booster started to work fine!

Thanks, Mike!

mike-fabian commented 3 months ago

Is it OK for you to do pip uninstall numpy? You are fine with the numpy which comes with Fedora 40?

psads-git commented 3 months ago

Yes, after removing numpy 2.0.1, everything returned to work normally.

Still, there is numpy in my computer:

$ rpm -qa python3-numpy
python3-numpy-1.26.4-3.fc40.x86_64
$

That is why nltk works fine now.

mike-fabian commented 3 months ago

I think I will add this commit to also catch the ValueError exception when trying to load nltk:

$ git show 
commit 44db2ae91f0e64180259de0303965c972b6e2b40 (HEAD -> release-candidate-2.25.15)
Author: Mike FABIAN <mfabian@redhat.com>
Date:   Sun Aug 25 22:05:13 2024 +0200

    Also catch ValueError exception when trying to import nltk

    Resolves: https://github.com/mike-fabian/ibus-typing-booster/issues/527

diff --git a/engine/hunspell_table.py b/engine/hunspell_table.py
index de8aa1b0..96767296 100644
--- a/engine/hunspell_table.py
+++ b/engine/hunspell_table.py
@@ -59,7 +59,7 @@ IMPORT_ITB_NLTK_SUCCESSFUL = False
 try:
     import itb_nltk
     IMPORT_ITB_NLTK_SUCCESSFUL = True
-except (ImportError, LookupError):
+except (ImportError, LookupError, ValueError):
     IMPORT_ITB_NLTK_SUCCESSFUL = False

 IMPORT_GOOGLE_SPEECH_TO_TEXT_SUCCESSFUL = False

That change should make typing booster work even if such an incompatible numpy is installed, only the nltk feature will be disabled automatically then.

psads-git commented 3 months ago

Is it OK for you to do pip uninstall numpy? You are fine with the numpy which comes with Fedora 40?

Yes, as I can use numpy 2.0.1 in a virtualenv, Mike.

mike-fabian commented 3 months ago

Probably nltk needs a fix to work with newer versions of numpy, but it is probably a good idea for me to catch ValueError as well.

mike-fabian commented 3 months ago

Great, so the problem is solved and I put the above commit in the next release just to avoid that anybody else runs into this problem when installing a newer numpy.

psads-git commented 3 months ago

There is a bug when working on WhatsApp, but I have not been able to identify the conditions of reproducing it. As soon I find them, I will report it, Mike.

psads-git commented 3 months ago

The bug occurs when one moves the cursor to words before, but I do not know how to reproduce it -- it adds the last typed word in the new cursor location, but, again, I do not know how to reproduce it.

mike-fabian commented 3 months ago

Yes, if you can reproduce it, please report a new issue.

mike-fabian commented 3 months ago
$ python3
Python 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
/usr/lib64/python3.12/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.0.1)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/nltk/__init__.py", line 133, in <module>
    from nltk.collocations import *
  File "/usr/lib/python3.12/site-packages/nltk/collocations.py", line 36, in <module>
    from nltk.metrics import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/__init__.py", line 18, in <module>
    from nltk.metrics.association import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/association.py", line 26, in <module>
    from scipy.stats import fisher_exact
  File "/usr/lib64/python3.12/site-packages/scipy/stats/__init__.py", line 608, in <module>
    from ._stats_py import *
  File "/usr/lib64/python3.12/site-packages/scipy/stats/_stats_py.py", line 39, in <module>
    from scipy.spatial.distance import cdist
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/__init__.py", line 110, in <module>
    from ._kdtree import *
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/_kdtree.py", line 4, in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
  File "_ckdtree.pyx", line 1, in init scipy.spatial._ckdtree
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
>>> 

To check whether catching ValueError as well avoids the problem, I also installed numpy-2.1.0:

mfabian@f40:~$ pip install --user --force numpy  
Collecting numpy
  Downloading numpy-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 kB 2.0 MB/s eta 0:00:00
Downloading numpy-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.0/16.0 MB 12.6 MB/s eta 0:00:00
Installing collected packages: numpy
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is 
the source of the following dependency conflicts.
contourpy 1.2.0 requires numpy<2.0,>=1.20, but you have numpy 2.1.0 which is incompatible.
scipy 1.11.3 requires numpy<1.28.0,>=1.21.6, but you have numpy 2.1.0 which is incompatible.
Successfully installed numpy-2.1.0
mfabian@f40:~$ 

During the installation it warns of an incompatibily with scipy 1.11.31 and that scipy also appears in the backtrace when doing import nltk.

mike-fabian commented 3 months ago

And then I can reproduce the problem when starting typing booster:

mfabian@f40:~$ /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py 
/usr/lib64/python3.12/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for 
this version of SciPy (detected version 2.1.0)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "/usr/share/ibus-typing-booster/engine/main.py", line 132, in <module>
    import factory
  File "/usr/share/ibus-typing-booster/engine/factory.py", line 37, in <module>
    import hunspell_table
  File "/usr/share/ibus-typing-booster/engine/hunspell_table.py", line 60, in <module>
    import itb_nltk
  File "/usr/share/ibus-typing-booster/engine/itb_nltk.py", line 37, in <module>
    import nltk # type: ignore
    ^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/nltk/__init__.py", line 133, in <module>
    from nltk.collocations import *
  File "/usr/lib/python3.12/site-packages/nltk/collocations.py", line 36, in <module>
    from nltk.metrics import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/__init__.py", line 18, in <module>
    from nltk.metrics.association import (
  File "/usr/lib/python3.12/site-packages/nltk/metrics/association.py", line 26, in <module>
    from scipy.stats import fisher_exact
  File "/usr/lib64/python3.12/site-packages/scipy/stats/__init__.py", line 608, in <module>
    from ._stats_py import *
  File "/usr/lib64/python3.12/site-packages/scipy/stats/_stats_py.py", line 39, in <module>
    from scipy.spatial.distance import cdist
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/__init__.py", line 110, in <module>
    from ._kdtree import *
  File "/usr/lib64/python3.12/site-packages/scipy/spatial/_kdtree.py", line 4, in <module>
    from ._ckdtree import cKDTree, cKDTreeNode
  File "_ckdtree.pyx", line 1, in init scipy.spatial._ckdtree
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
mfabian@f40:~$ 
mike-fabian commented 3 months ago

Fix included in ibus-typing-booster 2.25.15 https://github.com/mike-fabian/ibus-typing-booster/releases/tag/2.25.15