解决opencv演示sample问题/安装python3缺少的numpy库

在macbook pro上,无法正常演示opencv自带的sample文件,显示没有numpy库。

发现如果使用python2是正常的,而是python3(也包括visual studio code)缺少对应的库,解决问题方法如下。

查看目前库

首先通过list命令,对比pip和pip3,即python2(mac自带)和python3相关库的情况,结果是python的非常少

pip list
pip3 list 

也可以用freeze命令。

pip3 freeze

安装numpy库

正常采用如下命令

pip3 install numpy

但是国外的源太慢,更换成科大的,速度飞起

pip3 install --index-url https://pypi.mirrors.ustc.edu.cn/simple/ numpy

下图是通过科大源安装matplotlib的情况,速度快如闪电。
Screen Shot 2021-02-17 at 11.03.13 PM

如下是国内源列表

    清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

    阿里云 http://mirrors.aliyun.com/pypi/simple/

    中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

    豆瓣(douban) http://pypi.douban.com/simple/

参考如下
国内源
pip vs pip3
numpy tutorial 1/official
numpy tutorials 2

Leave a Reply

Your email address will not be published. Required fields are marked *