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<?, ?it/s]
Examining @/win-64::__archspec==1=x86_64: 0%| | 0/4 [00:00<?, ?it/s]
Examining opencv: 25%|██▌ | 1/4 [00:00<?, ?it/s]
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<?, ?it/s]
Examining conflict for opencv python: 0%| | 0/4 [00:00<?, ?it/s]
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都有问题,,,不容易!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容