无法降级numpy以兼容librosa 0.8.1

0 投票
1 回答
58 浏览
提问于 2025-04-14 17:01

我需要使用 librosa 0.8.1 这个版本,因为它和我的项目兼容,但我似乎无法降级到这个版本。其实我可以降级,但由于和最新版本的 numpy 不兼容,再加上我无法降级 numpy,这让我无法使用 librosa

我最开始用 pip install librosa==0.8.1 来安装我需要的 librosa 版本。但是,当我尝试把它导入到我的项目中时,出现了 numpy 的包错误。

AttributeError: module 'numpy' has no attribute 'complex'.
`np.complex` was a deprecated alias for the builtin `complex`. 
To avoid this error in existing code, use `complex` by itself. 
Doing this will not modify any behavior and is safe. 
If you specifically wanted the numpy scalar type, use `np.complex128` here.
The aliases was originally deprecated in NumPy 1.20.

看起来 librosa 0.8.1numpy 1.26.4 不兼容。但是,这个 numpy 版本是在我运行 pip install librosa==0.8.1 时自动安装的。这个问题在 librosa 0.9.x 中似乎已经解决了,但我需要的是之前的版本。

我尝试了 pip uninstall numpy 然后用 pip install numpy=1.19.2 来降级,但这失败了,出现了错误。

ModuleNotFoundError: No module named 'setuptools.extern.six'

我还尝试了 pip install --upgrade numpy==1.19.2pip install --force-reinstall numpy==1.19.2。我也试过用 pip3 安装不同版本的 numpy 1.19.5,结果都是同样的错误。我已经安装了最新版本的 setuptools

我还尝试了 python -m pip,尽管我机器上只有一个版本的 Python(python 3.12.2 x64)。这也失败了。

我不确定问题出在 setuptools 上,还是有没有其他方法可以降级 numpy。如果不能降级 numpy 我也没关系,我只想用 librosa 0.8.1,不想因为不兼容的错误而受阻。

任何帮助都将非常感谢!

1 个回答

0

如果你先卸载了numpy,然后再安装 pip install librosa==0.8.1,那么它会自动安装numpy,因为这是它需要的依赖。

撰写回答