python - 在 Windows 10 上安装外部库出错
问题描述
我正在尝试安装收缩包(https://pypi.org/project/contractions/),但此错误不断出现。尝试安装 Microsoft Visual C++,但它只下载一个安装程序,然后我找不到具体的东西。有人可以帮我解决这个问题吗?
编辑:我显然也尝试过 justpip install contractions
和wheel
doc。
C:\Users\CatKa\Documents\MSc\MACHINE LEARNING>python -m pip install contractions
Collecting contractions
Using cached https://files.pythonhosted.org/packages/85/41/c3dfd5feb91a8d587ed1a59f553f07c05f95ad4e5d00ab78702fbf8fe48a/contractions-0.0.24-py2.py3-none-any.whl
Collecting textsearch
Using cached https://files.pythonhosted.org/packages/42/a8/03407021f9555043de5492a2bd7a35c56cc03c2510092b5ec018cae1bbf1/textsearch-0.0.17-py2.py3-none-any.whl
Collecting pyahocorasick
Using cached https://files.pythonhosted.org/packages/f4/9f/f0d8e8850e12829eea2e778f1c90e3c53a9a799b7f412082a5d21cd19ae1/pyahocorasick-1.4.0.tar.gz
Requirement already satisfied: Unidecode in c:\users\catka\anaconda3\lib\site-packages (from textsearch->contractions) (1.1.1)
Building wheels for collected packages: pyahocorasick
Building wheel for pyahocorasick (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\CatKa\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-5amje9u5\\pyahocorasick\\setup.py'"'"'; __file__='"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-5amje9u5\\pyahocorasick\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\CatKa\AppData\Local\Temp\pip-wheel-ky0_mxbr' --python-tag cp37
cwd: C:\Users\CatKa\AppData\Local\Temp\pip-install-5amje9u5\pyahocorasick\
Complete output (5 lines):
running bdist_wheel
running build
running build_ext
building 'ahocorasick' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Failed building wheel for pyahocorasick
Running setup.py clean for pyahocorasick
Failed to build pyahocorasick
Installing collected packages: pyahocorasick, textsearch, contractions
Running setup.py install for pyahocorasick ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\CatKa\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-5amje9u5\\pyahocorasick\\setup.py'"'"'; __file__='"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-5amje9u5\\pyahocorasick\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\CatKa\AppData\Local\Temp\pip-record-69ndyre4\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\CatKa\AppData\Local\Temp\pip-install-5amje9u5\pyahocorasick\
Complete output (5 lines):
running install
running build
running build_ext
building 'ahocorasick' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\CatKa\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-5amje9u5\\pyahocorasick\\setup.py'"'"'; __file__='"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-5amje9u5\\pyahocorasick\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\CatKa\AppData\Local\Temp\pip-record-69ndyre4\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
编辑 2:安装了 Visual C++,就像它说的那样(https://www.scivision.co/python-windows-visual-c-14-required/),还安装了这里提供的Visual C++ 14.0 (需要 Microsoft Visual C++ 14.0 (无法找到 vcvarsall.bat))但现在错误部分更大
C:\Users\CatKa\Documents\MSc\MACHINE LEARNING>pip install contractions
Collecting contractions
Using cached https://files.pythonhosted.org/packages/85/41/c3dfd5feb91a8d587ed1a59f553f07c05f95ad4e5d00ab78702fbf8fe48a/contractions-0.0.24-py2.py3-none-any.whl
Collecting textsearch
Using cached https://files.pythonhosted.org/packages/42/a8/03407021f9555043de5492a2bd7a35c56cc03c2510092b5ec018cae1bbf1/textsearch-0.0.17-py2.py3-none-any.whl
Requirement already satisfied: Unidecode in c:\users\catka\anaconda3\lib\site-packages (from textsearch->contractions) (1.1.1)
Collecting pyahocorasick
Using cached https://files.pythonhosted.org/packages/f4/9f/f0d8e8850e12829eea2e778f1c90e3c53a9a799b7f412082a5d21cd19ae1/pyahocorasick-1.4.0.tar.gz
Building wheels for collected packages: pyahocorasick
Building wheel for pyahocorasick (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\catka\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-nx9373pl\\pyahocorasick\\setup.py'"'"'; __file__='"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-nx9373pl\\pyahocorasick\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\CatKa\AppData\Local\Temp\pip-wheel-mg8rchse' --python-tag cp37
cwd: C:\Users\CatKa\AppData\Local\Temp\pip-install-nx9373pl\pyahocorasick\
Complete output (23 lines):
running bdist_wheel
running build
running build_ext
building 'ahocorasick' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DAHOCORASICK_UNICODE= -Ic:\users\catka\anaconda3\include -Ic:\users\catka\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" /Tcpyahocorasick.c /Fobuild\temp.win-amd64-3.7\Release\pyahocorasick.obj
pyahocorasick.c
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(363): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(422): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(473): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(483): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\src/custompickle/load/loadbuffer.c(68): warning C4146: unary minus operator applied to unsigned type, result still unsigned
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\src/custompickle/load/module_automaton_load.c(89): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
creating C:\Users\CatKa\AppData\Local\Temp\pip-install-nx9373pl\pyahocorasick\build\lib.win-amd64-3.7
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\catka\anaconda3\libs /LIBPATH:c:\users\catka\anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64" /EXPORT:PyInit_ahocorasick build\temp.win-amd64-3.7\Release\pyahocorasick.obj /OUT:build\lib.win-amd64-3.7\ahocorasick.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\ahocorasick.cp37-win_amd64.lib
pyahocorasick.obj : warning LNK4197: export 'PyInit_ahocorasick' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.7\Release\ahocorasick.cp37-win_amd64.lib and object build\temp.win-amd64-3.7\Release\ahocorasick.cp37-win_amd64.exp
Generating code
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158
----------------------------------------
ERROR: Failed building wheel for pyahocorasick
Running setup.py clean for pyahocorasick
Failed to build pyahocorasick
Installing collected packages: pyahocorasick, textsearch, contractions
Running setup.py install for pyahocorasick ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\catka\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-nx9373pl\\pyahocorasick\\setup.py'"'"'; __file__='"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-nx9373pl\\pyahocorasick\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\CatKa\AppData\Local\Temp\pip-record-82y3clbc\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\CatKa\AppData\Local\Temp\pip-install-nx9373pl\pyahocorasick\
Complete output (23 lines):
running install
running build
running build_ext
building 'ahocorasick' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DAHOCORASICK_UNICODE= -Ic:\users\catka\anaconda3\include -Ic:\users\catka\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" /Tcpyahocorasick.c /Fobuild\temp.win-amd64-3.7\Release\pyahocorasick.obj
pyahocorasick.c
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(363): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(422): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(473): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\Automaton_pickle.c(483): warning C4018: '<': signed/unsigned mismatch
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\src/custompickle/load/loadbuffer.c(68): warning C4146: unary minus operator applied to unsigned type, result still unsigned
c:\users\catka\appdata\local\temp\pip-install-nx9373pl\pyahocorasick\src/custompickle/load/module_automaton_load.c(89): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
creating C:\Users\CatKa\AppData\Local\Temp\pip-install-nx9373pl\pyahocorasick\build\lib.win-amd64-3.7
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\catka\anaconda3\libs /LIBPATH:c:\users\catka\anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64" /EXPORT:PyInit_ahocorasick build\temp.win-amd64-3.7\Release\pyahocorasick.obj /OUT:build\lib.win-amd64-3.7\ahocorasick.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\ahocorasick.cp37-win_amd64.lib
pyahocorasick.obj : warning LNK4197: export 'PyInit_ahocorasick' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.7\Release\ahocorasick.cp37-win_amd64.lib and object build\temp.win-amd64-3.7\Release\ahocorasick.cp37-win_amd64.exp
Generating code
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\catka\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-nx9373pl\\pyahocorasick\\setup.py'"'"'; __file__='"'"'C:\\Users\\CatKa\\AppData\\Local\\Temp\\pip-install-nx9373pl\\pyahocorasick\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\CatKa\AppData\Local\Temp\pip-record-82y3clbc\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
解决方案
我在使用 pip 安装时收到了同样的错误,并尝试“conda Channel”进行安装,它成功了。
在 Anaconda Navigator 的 Powershell 提示符下尝试以下命令
conda config --add channels conda-forge
conda install pyahocorasick
推荐阅读
- reactjs - reactjs本地与部署问题
- amazon-s3 - 如果一切都已设置好,修改 S3 对象将反映在云端
- python - Numpy Python - 在 numpy 矩阵的索引列表中插入矩阵
- r - 交换代理人
- python-3.x - AttributeError: 'list' 对象没有属性 'argmax' 和 numpy.AxisError: 轴 2 超出维度 1 数组的范围
- youtube - youtube 帐户 ID、播放列表 ID 或视频 ID 是否会定期自动更改或更新?
- xslt-3.0 - XSLT 函数结果中的意外元素
- c++ - 这是像 learncpp.com 声称的 GCC 错误吗?
- python - 有没有一种方法可以在 python 中使用 lambda 函数来删除第一次出现
- javascript - 停止正在运行的 javascript 函数