- lap是使用Jonker-Volgenant算法求解稠密(LAPJV)或稀疏(LAPMOD)矩陣的線性分配問題求解器
- 為了使用模塊lap,結(jié)果
pip install lap
安裝失敗,命令行提示如下:
ERROR: Command errored out with exit status 1:
command: 'D:\Anaconda3\envs\tensorflow\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\MSI\\AppData\\Local\\Temp\\pip-req-build-9w1k0u2r\\setup.py'"'"'; __file__='"'"'C:\\Users\\MSI\\AppData\\Local\\Temp\\pip-req-build-9w1k0u2r\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\MSI\AppData\Local\Temp\pip-record-xqcdmil9\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda3\envs\tensorflow\Include\lap'
cwd: C:\Users\MSI\AppData\Local\Temp\pip-req-build-9w1k0u2r\
Complete output (30 lines):
Partial import of lap during the build process.
Generating cython files
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "lap._lapjv" sources
building data_files sources
build_src: building npy-pkg config files
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\lap
copying lap\lapmod.py -> build\lib.win-amd64-3.7\lap
copying lap\__init__.py -> build\lib.win-amd64-3.7\lap
running build_ext
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
customize MSVCCompiler using build_ext
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
Missing compiler_cxx fix for MSVCCompiler
customize MSVCCompiler using build_ext
building 'lap._lapjv' extension
compiling C sources
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/
----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\Anaconda3\envs\tensorflow\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\MSI\\AppData\\Local\\Temp\\pip-req-build-9w1k0u2r\\setup.py'"'"'; __file__='"'"'C:\\Users\\MSI\\AppData\\Local\\Temp\\pip-req-build-9w1k0u2r\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\MSI\AppData\Local\Temp\pip-record-xqcdmil9\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda3\envs\tensorflow\Include\lap' Check the logs for full command output.
一開始在lap的github官網(wǎng)上看見說需要有c的編譯器:lap的官方鏈接
Install from source
Install a C++ compiler (e.g., g++)
Python headers (e.g., python-dev package on Debian/Ubuntu)
Install Cython (>=0.21)
考慮到電腦上并沒有安裝有關(guān)C編譯的軟件,看了下面的解決方案之后:
https://stackoverflow.com/questions/66838238/cython-setup-py-cant-find-installed-visual-c-build-tools/68553226#68553226
- 首先在命令行中查看自己的
MSVC version
:
python -c "import sys; print(sys.version)"
我的是1916的版本
D:\Program Files (x86)\Microsoft Visual Studio\2017\Community>python -c "import sys; print(sys.version)"
3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)]
對應(yīng)的Visual Studio版本是2017,可以在下面的網(wǎng)址自行查看:
https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B
重點來了?。?!
在安裝Visual Studio一開始要選擇工作負(fù)載!我一開始直接默認(rèn),導(dǎo)致我又失敗了!
后面看了這篇博客Microsoft visual C++ build tools安裝包丟失
我已經(jīng)安裝好了,所以需要重新從這里進(jìn)去工作負(fù)載選擇:
注意!!勾選只用C++的桌面開發(fā)!
旁邊的可選保持默認(rèn)就可以了!文章來源:http://www.zghlxwxcb.cn/news/detail-443565.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-443565.html
- 重新回到命令行
pip
安裝,安裝成功!
看完之后如果解決問題啦!記得評論點個贊!
到了這里,關(guān)于【python】安裝模塊lap出錯: error: Microsoft Visual C++ 14.0 or greater is required.的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!