- lap是使用Jonker-Volgenant算法求解稠密(LAPJV)或稀疏(LAPMOD)矩阵的线性分配问题求解器
- 为了使用模块lap,结果
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官网上看见说需要有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)
考虑到电脑上并没有安装有关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)]
对应的Visual Studio版本是2017,可以在下面的网址自行查看:
https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B
重点来了!!!
在安装Visual Studio一开始要选择工作负载!我一开始直接默认,导致我又失败了!
后面看了这篇博客Microsoft visual C++ build tools安装包丢失
我已经安装好了,所以需要重新从这里进去工作负载选择:
注意!!勾选只用C++的桌面开发!
旁边的可选保持默认就可以了!文章来源:https://www.toymoban.com/news/detail-443565.html
文章来源地址https://www.toymoban.com/news/detail-443565.html
- 重新回到命令行
pip
安装,安装成功!
看完之后如果解决问题啦!记得评论点个赞!
到了这里,关于【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!