2021-11-30 【解决】pyautogui 安装opencv,ImportError: DLL load failed问题,原因是win server 2012

安装PyautoGui,用到了confidence参数,需要opencv,装之。自己电脑用着没问题,换服务器各种问题
pyautogui.locateOnScreen(pic,confidence=0.8)
怀疑是python版本问题
python 3.6.4 不行
3.7不行
raise NotImplementedError('The confidence keyword argument is only available if OpenCV is installed.')

怀疑opencv-python 安装问题,说版本不匹配的大把:
import cv2 出现“ImportError: DLL load failed: 找不到指定的模块"
已经安装了opencv-python, pip install opencv-python

有台服务器升级anaconda最新版本,版本是python3.9,解决了,但是还有好多台服务器不能用

搜索引擎查找导致这个的各种问题,各种尝试,都不行


image.png

想尝试用conda看看有没有其他相关包
输入 ‘conda install opencv’

返回

Note: you may need to restart the kernel to use updated packages.
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Solving environment: ...working... failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Solving environment: ...working...
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed

Building graph of deps: 0%| | 0/4 [00:00 Examining @/win-64::__archspec==1=x86_64: 0%| | 0/4 [00:00 Examining opencv: 25%|██▌ | 1/4 [00:00 Examining python=3.9: 50%|█████ | 2/4 [00:00<00:00, 22.97it/s]
Examining @/win-64::__win==0=0: 75%|███████▌ | 3/4 [00:00<00:00, 18.51it/s]
Examining @/win-64::__win==0=0: 100%|██████████| 4/4 [00:00<00:00, 24.68it/s]
Determining conflicts: 0%| | 0/4 [00:00 Examining conflict for opencv python: 0%| | 0/4 [00:00 UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:

opencv -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3.7,<3.8.0a0']
Your python: python=3.9
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
不明所以

看到个说把cv2文件夹中的东西改改,


image.png

改了,还是不行

最后这样解决的,发现我用的是win server2012b,找到了这个帖子,

Windows Server 2012 r2服务器下import cv2 出现ImportError: DLL load failed

服务器上安装 桌面体验 这个功能就可以了
参考文章安装 https://blog.csdn.net/XHW___001/article/details/85783582
重要的是这一步,其他有些文章提到的媒体体验不用选(也分情况,介于这么多种原因,如这样不行请选中)

image.png

安装完重启后会提示:


image.png

image.png

没问题了,导入import cv2
这部分停了快一个礼拜了,,奶茶庆祝一下!!
总结:
在用的win server2016,win10 1903版本使用和安装都没问题,只有win server 2012都有问题,,,不容易!

你可能感兴趣的:(2021-11-30 【解决】pyautogui 安装opencv,ImportError: DLL load failed问题,原因是win server 2012)