从pyxdameraulevenshtein导入会出现以下错误
pyxdameraulevenshtein==1.5.3
pandas==1.1.4
scikit-learn==0.20.2.
Numpy是1.16.1。
在Python 3.6中工作良好,在Python 3.7中问题。
有人在使用Python 3.7(3.7.9)时遇到过类似的问题吗?
from pyxdameraulevenshtein import normalized_damerau_levenshtein_distance as norm_dl_dist
__init__.pxd:242: in init pyxdameraulevenshtein
???
E ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
我在python3.10.4,numpy1.21.5中遇到了同样的问题,我只有在通过pip卸载numpy和pip安装numpy将numpy更新到1.22.3后才解决了这个问题。只有pip install -upgrade numpy没有工作。
PS D:\quant\vnpy-master\examples\veighna_trader> python .\run.py
Traceback (most recent call last): File
"D:\quant\vnpy-master\examples\veighna_trader\run.py", line 31, in
from vnpy_optionmaster import OptionMasterApp File
"D:\it_soft\python3.10.4\Lib\site-packages\vnpy_optionmaster__init__.py",
line 26, in from .engine import OptionEngine, APP_NAME File
"D:\it_soft\python3.10.4\Lib\site-packages\vnpy_optionmaster\engine.py",
line 34, in from .pricing import binomial_tree_cython as
binomial_tree File "binomial_tree_cython.pyx", line 1, in init
binomial_tree_cython ValueError: numpy.ndarray size changed, may
indicate binary incompatibility. Expected 96 from C header, got 88
from PyObject
这对我很有用(当这一页上的任何东西都不起作用时):
# Create environment with conda or venv.
# Do *not* install any other packages here.
pip install numpy==1.21.5
# Install all other packages here.
# This works as a package may build against the currently installed version of numpy.
这解决了一个特别残酷的问题,截至2022-04-11,本页上的所有其他答案都无法解决:
其他答案试图在问题发生后解决问题,这种方法在问题发生前解决问题。
此外,可以尝试不同版本的Python,例如3.8、3.9、3.10。
@FZeiser的回答很好,解释了为什么这种方法有效。