正常安装流程
- 安装最新版本的python,我的是Python3.9.0,官网下载安装即可
- 安装 opencv ,cmd.exe进入python的安装目录,进入目录Programs\Python\Python39\Lib\site-packages,cmd要管理员权限,安装命令
pip install opencv-python
非常顺利 - 安装numpy
pip install numpy
安装成功
测试:python进入命令行
import cv2
import numpy
出错
The current Numpy installation () fails to pass a sanity check due to a bug in the windows runtime
-
好吧,听说安装windows运行时程序管用,装了一个重启
下载地址
https://dl1.qwp365.cn/luo/3DMAGME-vcredist2015_x64.zip
这个不知道管不管用,但是还是出错 -
按照提示,找到了官网,开发团队有回答如下
https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html
下面是管用的一句话
As a workaround, you temporarily pin to NumPy 1.19.3 (pip install numpy==1.19.3
) which has a fixed version of OpenBLAS that works correctly in Windows 2004/20H2. This fix broken other things (Linux, Windows-on-docker) and so could not be retained in NumPy 1.19.4.
大概就是降级到numpy1.19.3
好的,执行
首先卸载numpy1.19.4
pip uninstall numpy
pip install numpy==1.19.3
再进入python命令行
import cv2
import numpy
一切ok了
D:\Users\xxx\AppData\Local\Programs\Python\Python39\Lib\site-packages>python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import cv2
>>>
网友评论