从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

当前回答

我在树莓派3中也面临着同样的问题。实际上这个错误发生在熊猫身上。虽然tensorflow需要numpy~=1.19.2,但是pandas不符合它。所以,我已经升级(因为降级不是)我的numpy到最新版本,一切都很好!!!!。

root@raspberrypi:/home/pi# python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np 
>>> np.__version__
'1.21.5'
>>> import pandas as pd
>>> pd.__version__
'1.3.5'
>>> import tensorflow as tf
>>> tf.__version__
'2.4.0'
>>> tf.keras.__version__
'2.4.0'
>>> tf.keras.layers
<module 'tensorflow.keras.layers' from '/usr/local/lib/python3.7/dist-packages/tensorflow/keras/layers/__init__.py'>

这里也有同样的问题- https://github.com/bitsy-ai/tensorflow-arm-bin/issues/5

Tensorflow来源:https://github.com/bitsy-ai/tensorflow-arm-bin

其他回答

在你安装任何包之后,确保你重新启动内核并且应该工作。通常包会自动升级,你所需要的只是快速重启。至少,这在我的情况下工作,当我试图安装和使用石榴时,我得到了同样的错误。

我在树莓派3中也面临着同样的问题。实际上这个错误发生在熊猫身上。虽然tensorflow需要numpy~=1.19.2,但是pandas不符合它。所以,我已经升级(因为降级不是)我的numpy到最新版本,一切都很好!!!!。

root@raspberrypi:/home/pi# python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np 
>>> np.__version__
'1.21.5'
>>> import pandas as pd
>>> pd.__version__
'1.3.5'
>>> import tensorflow as tf
>>> tf.__version__
'2.4.0'
>>> tf.keras.__version__
'2.4.0'
>>> tf.keras.layers
<module 'tensorflow.keras.layers' from '/usr/local/lib/python3.7/dist-packages/tensorflow/keras/layers/__init__.py'>

这里也有同样的问题- https://github.com/bitsy-ai/tensorflow-arm-bin/issues/5

Tensorflow来源:https://github.com/bitsy-ai/tensorflow-arm-bin

对于任何使用诗歌的人来说,有必要进行实验。对于numpy<1.20依赖项的应用程序,New-installer设置为true才能正确构建,即:

poetry config experimental.new-installer true

默认情况下是正确的,但如果它被改变了(就像我的情况一样),它会让你识破。

我的应用程序使用Tensorflow,因此我没有升级到>1.20的选项。诗歌也不支持无二进制依赖。

尝试使用numpy==1.20.0,它在这里可以工作,尽管其他情况不同(alpine 3.12上的python3.8)。

这对我很有用(当这一页上的任何东西都不起作用时):

# 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的回答很好,解释了为什么这种方法有效。