[英]Pip install results in this error " cl.exe' failed with exit code 2 "
I've read all of the other questions on this error and frustratingly enough, none give a solution that works.我已经阅读了关于此错误的所有其他问题,但令人沮丧的是,没有一个提供有效的解决方案。
If I run pip install sentencepiece
in the cmd line, it gives me the following output.如果我在 cmd 行中运行
pip install sentencepiece
,它会给出以下 output。
src/sentencepiece/sentencepiece_wrap.cxx(2809): fatal error C1083: Cannot open include file: 'sentencepiece_processor.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
I'm running python 3.10.1 and pip 22.0.3.我正在运行 python 3.10.1 和 pip 22.0.3。
*I have the following Microsoft Visual C++ programs on my windows machine,which I've just done a fresh install of as it was complaining of not having a particular C++ program. *我的 windows 机器上有以下 Microsoft Visual C++ 程序,我刚刚完成了全新安装,因为它抱怨没有特定的 C++ 程序。 MS VC++
微软VC++
I've even added the.exe file to my PATH variables but still I get the same error.我什至将 .exe 文件添加到我的 PATH 变量中,但我仍然遇到同样的错误。
Am I missing a particular Microsoft program on my pc?我的电脑上是否缺少特定的 Microsoft 程序?
I haven't seen this problem in Windows, but for Linux, I would normally reinstall Python after installing the dependencies (such as the MSVC thing).我在Windows没有看到这个问题,但是对于Linux,我一般会在安装依赖项(比如MSVC的东西)后重新安装Python。 In that case this is especially helpful because I'm often rebuilding (compiling and other related steps) Python/Pip.
在那种情况下,这特别有用,因为我经常重建(编译和其他相关步骤)Python/Pip。
Could also just be an error specific to the module and Python version combo you're trying.也可能只是特定于您正在尝试的模块和 Python 版本组合的错误。
From a discussion in the comments:来自评论中的讨论:
I have the pyenv-win version manager, so I was able to create venvs and test this for you.我有pyenv-win版本管理器,所以我能够创建venvs并为你测试它。 With Python 3.10.2, it fails;
使用 Python 3.10.2,失败; with Python 3.8.10, it's successful.
使用 Python 3.8.10,成功。 So, yes, reinstalling does seem to be worthy of your time.
所以,是的,重新安装似乎值得您花时间。
With python3.10用python3.10
On Windows: First, install vcpkg and install sentencepiece:x64-windows-static
Windows上:首先
install vcpkg and install sentencepiece:x64-windows-static
copy the header and lib files from vcpkg/installed/x64-windows-static/include
and lib to将 header 和 lib 文件从
vcpkg/installed/x64-windows-static/include
和 lib 复制到
C:/Program Files/python310/build/root/include
and lib C:/Program Files/python310/build/root/include
and lib
This should work as the setup.py install expects the library in a..\build\root\lib directory.这应该可以正常工作,因为 setup.py 安装期望库位于 ..\build\root\lib 目录中。
As the C:\Program Files\python310\lib is in the /LIBPATH, the resulting..\build\root\lib will point to the sentencepiece.lib由于 C:\Program Files\python310\lib 在 /LIBPATH 中,因此生成的 ..\build\root\lib 将指向 sentencepiece.lib
If still encounting errors, then set the INCLUDE and LIB environment variables so that the cl.exe, which is called from pip install sentencetransformers
finds them.如果仍然遇到错误,则设置 INCLUDE 和 LIB 环境变量,以便从
pip install sentencetransformers
调用的 cl.exe 找到它们。
People having windows+python 3.10 env, here are exact steps to install it via vcpkg.拥有 windows+python 3.10 env 的人,这里是通过 vcpkg 安装它的确切步骤。
Other instructions are covered in zweistein's answer. zweistein 的回答中涵盖了其他说明。
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install sentencepiece:x64-windows-static
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.