r9y9 / pyopenjtalk

Python wrapper for OpenJTalk
https://r9y9.github.io/pyopenjtalk/
Other
203 stars 69 forks source link

Numpy raised ValueError when importing pyopenjtalk #42

Closed Aria-K-Alethia closed 1 year ago

Aria-K-Alethia commented 2 years ago

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 2 years ago

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
Aria-K-Alethia commented 2 years ago

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 2 years ago

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

sabonerune commented 1 year ago

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.