验证numpy是否安装的小技巧

numpy

如下

>>> from numpy import *
>>> eye(4)
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

Brew

mac更新到big sur之后,brew运行就不正常。在发现使用更新中科大源之前,我才用的是如下方法,也能解决问题,只不过在imac上可以正常安装opencv,而mac pro上则失败了,后来在两台电脑上全部重新安装了中科大版本的brew,才最终解决,下面将原操作做个记录。

  • 首先,在使用brew list或brew doctor后,出现的是下面的问题

    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:37: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)>'
  • 然后,删除xcode工具,并重新安装

    sudo rm -rf /Library/Developer/CommandLineTools
    sudo xcode-select --install
    
  • 最后,更新brew即可

    brew upgrade
    

    当然,最好的方法是

    brew update-reset
    brew cleanup
    

    参考
    brew更新问题
    更换科大brew源

brew和zsh的小问题

brew

昨天开始学习opencv,一天时间把环境都没有搞好,主要是mac系统升级到big sur以后,brew出现了很多告警,而且跟新起来除了很多问题,包括使用【brew update-reset】重新安装xcode tools也不行,终于下定决心,重新安装brew,问题基本搞定,安装脚本如下

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

然后依次安装opencv和scipy库

brew doctor
brew install python(我已经安装好了)
brew install opencv
brew install scipy

查看opencv版本如下

opencv_version

ZSH

使用国内中科大的源,安装完brew后,每次打开terminal,会出现如下提示

[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxrwx 7 hans admin 238 2 9 10:13 /usr/local/share/zsh
drwxrwxrwx 6 hans admin 204 10 1 2017 /usr/local/share/zsh/site-functions

大意是zsh认为目录权限有问题,解决方法如下

chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions

参考
1 zsh问题
2 brew中科大源