【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.

这篇具有很好参考价值的文章主要介绍了【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

  • 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安装包丢失
我已经安装好了,所以需要重新从这里进去工作负载选择:
【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.

注意!!勾选只用C++的桌面开发!旁边的可选保持默认就可以了!

【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.文章来源地址https://www.toymoban.com/news/detail-443565.html

  • 重新回到命令行pip安装,安装成功!
    【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.
    看完之后如果解决问题啦!记得评论点个赞!

到了这里,关于【python】安装模块lap出错: error: Microsoft Visual C++ 14.0 or greater is required.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包