解决brew安装opencv报错问题

1 篇文章 0 订阅
文章详细描述了在Mac上使用brew安装OpenCV时遇到的两个错误及解决方法。第一个错误是由于brew的版本问题,通过执行`brewupdate-reset`可以解决。第二个错误是portable-ruby文件下载校验和不匹配,需要手动下载正确的文件并拷贝到指定目录。
摘要由CSDN通过智能技术生成

1.报错1

mac本用brew报如下错误:

xialiangzhideMacBook-Pro:~ xialz$ brew install opencv
Traceback (most recent call last):
	11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'
	10: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
	 9: from /usr/local/Homebrew/Library/Homebrew/global.rb:29:in `<top (required)>'
	 8: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 7: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 6: from /usr/local/Homebrew/Library/Homebrew/os.rb:3:in `<top (required)>'
	 5: from /usr/local/Homebrew/Library/Homebrew/os.rb:21:in `<module:OS>'
	 4: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:58:in `prerelease?'
	 3: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `version'
	 2: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `new'
	 1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:26:in `initialize'
/usr/local/Homebrew/Library/Homebrew/version.rb:368:in `initialize': Version value must be a string; got a NilClass () (TypeError)

2. 解决方案

网上上搜索以后,有的说是因为brew只支持正式发行版。/usr/local/Homebrew/Library/Homebrew/version.rb文件中第368行直接用@version = '10.14.1’给定一个版本号就可以了。但是我修改了以后,没有用。因为每次启动brew命令后/usr/local/Homebrew/Library/Homebrew/version.rb文件就会恢复为原来的样子,错误依旧。
没有办法,那么就重置吧:brew update-reset然后就OK了。

参考链接:http://www.manongjc.com/detail/41-jhgtmblbewnpkjn.html

3. 报错2

brew install opencv
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:1f50bf80583bd436c9542d4fa5ad47df0ef0f0bea22ae710c4f04c42d7560bca
Already downloaded: /Users/xialz/Library/Caches/Homebrew/portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz
Error: Checksum mismatch.
Expected: 1f50bf80583bd436c9542d4fa5ad47df0ef0f0bea22ae710c4f04c42d7560bca
  Actual: 6ae9f559ac4f90b92cae96c25a7486ee389ec0d7082910344a1afaf85ae6b301
 Archive: /Users/xialz/Library/Caches/Homebrew/portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz
To retry an incomplete download, remove the file above.
Error: Failed to upgrade Homebrew Portable Ruby!

4. 解决方案

4.1 原因分析

是由于文件portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz下载失败导致的

4.2 手动下载portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz

https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8_1/portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz

4.3 拷贝portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz到指定目录

cp portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz  /Users/xialz/Library/Caches/Homebrew/

=mac上使用clion搭建opencv开发环境=
mac上使用clion搭建opencv开发环境

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值