最终解决的方法如下:
git clone https://github.com/huggingface/neuralcoref.git
cd neuralcoref
pip install -r requirements.txt
python setup.py install
原始步骤:
安装 neuralcoref
的依赖:
- 安装编译
neuralcoref
所需的依赖项,例如cython
和numpy
neuralcoref
依赖于SpaCy
,确保已经安装了SpaCy
和它的所有依赖项- 根据错误信息,
tables
需要blosc2
库
pip install -U spacy
pip install -U cython numpy
pip install blosc2
pip install tables
安装 neuralcoref
:
- 再次安装
neuralcoref
pip install neuralcoref
仍然失败:
检查并更新 pip、setuptools 和 wheel:
- 确保你使用的是最新版本的
pip
、setuptools
和wheel
pip install --upgrade pip setuptools wheel
仍然失败,git下载:
git clone https://github.com/huggingface/neuralcoref.git
cmd里的下载不稳定失败了一次,用githubdesktop下载稳定。下载完后pip install
pip install -r requirements.txt
如果下载失败,手动打开requirements.txt,用清华源镜像下载。
spacy>=2.1.0,<3.0.0
cython>=0.25
pytest
pip install pytest -i https://pypi.tuna.tsinghua.edu.cn/simple
显示错误信息:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
confection 0.1.5 requires srsly<3.0.0,>=2.4.0, but you have srsly 1.0.7 which is incompatible.
en-core-web-sm 3.7.1 requires spacy<3.8.0,>=3.7.2, but you have spacy 2.3.9 which is incompatible.
weasel 0.4.1 requires srsly<3.0.0,>=2.4.3, but you have srsly 1.0.7 which is incompatible.
Successfully installed catalogue-1.0.2 plac-1.1.3 spacy-2.3.9 srsly-1.0.7 thinc-7.4.6 wasabi-0.10.1
C:\Users\Xheng1934\Desktop\1neuralcoref\neuralcoref>
这个错误表明 pip
的依赖解析器在安装过程中遇到了多个包版本不兼容的情况,特别是关于 srsly
和 spacy
的版本问题。
用release的whl下载:
neuralcoref-4.0-cp37-cp37m-win_amd64.whl
仍然失败。
考虑到是spacy的版本冲突,故卸载最新版本3.7.0,改安装网上推荐的2.1.0。直接pip安装失败,故用gz文件安装,在github的release中找到2.1.0版本,下载gz安装包,20MB左右,输入命令:
pip install spacy-2.1.0.tar.gz
仍然失败,不是安装的网络问题或者版本冲突,而是2.1.0里面的 spacy-2.1.0.tar.gz
文件中的 pyproject.toml
文件中包含了一个不合法的 build-system.requires
键。这个键指定了构建项目所需的依赖项,但其格式不符合 PEP 518 的规范。
网上对neuralcoref的安装介绍很少,基本上都要求安装spacy的2.1.0版本。可能是python3.11和spacy2.1.0版本不兼容。但是卸载py11安装py7又太麻烦。
最终还是重新安装了spacy的3.7.5版本。没有安装neuralcoref。最后的报错信息是:
running build_ext
building 'neuralcoref.neuralcoref' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for neuralcoref
Running setup.py clean for neuralcoref
Failed to build neuralcoref
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (neuralcoref)
C:\WINDOWS\system32>
这个错误表明需要安装 Microsoft Visual C++ 14.0 或更高版本的编译工具,才能在 Windows 系统上构建 neuralcoref
包。这是因为 neuralcoref
包含有原生的 C 或 C++ 代码扩展。
可见,要求VS版本如下:
Microsoft Visual C++ 14.0 or greater is required
查看自己的 Visual Studio 版本:
- 打开 Visual Studio:
- 在 Windows 桌面或开始菜单中找到并打开 Visual Studio。
- 查看版本信息:
- 打开 Visual Studio 后,点击顶部菜单栏中的 帮助 (Help),然后选择 关于 Microsoft Visual Studio (About Microsoft Visual Studio)。
- 查看版本号:
- 在弹出的关于对话框中,您可以看到安装的 Visual Studio 的版本号和详细信息。通常版本号会显示在对话框的标题或主体区域中。
仍然失败,如下:
"E:\visual studio\VC\Tools\MSVC\14.40.33807\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IE:\Anaconda\include -IC:\Users\Xheng1934\AppData\Local\Temp\pip-install-drmcxqgy\neuralcoref_2f9b3f26a81f4dfd87d4aeb39db93ee1\include -IE:\Anaconda\include -IE:\Anaconda\Include "-IE:\visual studio\VC\Tools\MSVC\14.40.33807\include" "-IE:\visual studio\VC\Tools\MSVC\14.40.33807\ATLMFC\include" "-IE:\visual studio\VC\Auxiliary\VS\include" "-ID:\Windows Kits\10\include\10.0.22621.0\ucrt" "-ID:\Windows Kits\10\\include\10.0.22621.0\\um" "-ID:\Windows Kits\10\\include\10.0.22621.0\\shared" "-ID:\Windows Kits\10\\include\10.0.22621.0\\winrt" "-ID:\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpneuralcoref/neuralcoref.cpp /Fobuild\temp.win-amd64-cpython-311\Release\neuralcoref/neuralcoref.obj /Ox /EHsc
neuralcoref.cpp
neuralcoref/neuralcoref.cpp(196): fatal error C1083: 无法打开包括文件: “longintrepr.h”: No such file or directory
error: command 'E:\\visual studio\\VC\\Tools\\MSVC\\14.40.33807\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for neuralcoref
Running setup.py clean for neuralcoref
Failed to build neuralcoref
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (neuralcoref)
C:\Users\Xheng1934>
解决失败。