r9y9/pyopenjtalk

Numpy raised ValueError when importing pyopenjtalk

Aria-K-Alethia opened this issue · 4 comments

Hi,

I always encounted the following error when I tried import pyopenjtalk:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/pyopenjtalk/pyopenjtalk/__init__.py", line 20, in <module>
    from .htsengine import HTSEngine
  File "pyopenjtalk/htsengine.pyx", line 1, in init pyopenjtalk.htsengine
    # coding: utf-8
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I suppose this is because the version of numpy is not compatible, so I tried a lot of versions including 1.22.x, 1.21.x, and 1.20.x, but I always failed.
Do you have any idea on this?

Below are my env information:

python=3.8.13
numpy=1.22.3

I installed pyopenjtalk via pip.

r9y9 commented

That's likely due to the build isolation feature of pip. Regardless of the NumPy versions you have, pip creates an isolated environment with a different version of numpy at installation time, causing the version mismatch. Could you try the following command?

pip install -U pyopenjtalk --no-build-isolation

Hi,

Thank you for your reply.

I installed successfully with the cmd:

pip install pyopenjtalk --no-build-isolation --no-binary pyopenjtalk

It seems that I also need to compile the source code again to install.

r9y9 commented

Thanks for sharing the information. We would need to better handle installation issues but no idea at the moment.

May be need to write the oldest version of numpy for each environment like SciPy.
https://github.com/scipy/scipy/blob/9a38213b51a56b45f49863f52bba002c2f49d71f/pyproject.toml#L21-L50

oldest-supported-numpy may be use.