❀安装第三方库❀win10,anaconda虚拟环境下安装cv2,numpy

这篇博客详细记录了在Python环境中安装opencv-python和numpy时遇到的问题,包括DLL加载失败、版本冲突和依赖冲突等。作者提供了详细的解决步骤,如卸载并重新安装numpy、使用特定版本以及检查环境配置。此外,还提到了dlib安装时numpy版本的注意事项。
摘要由CSDN通过智能技术生成

安装cv2指的是opencv-python

Step1:激活想要安装的所在虚拟环境

然后安装

pip install opencv-python

Step2:激活想要安装的所在虚拟环境

Step3:检测是否可用

没有报错就是安装完成。

安装numpy,遇到的错误及解决办法

Step1:激活想要安装的所在虚拟环境Pip install numpy

(黄色字部分为原因及解决办法)一般第一次安装使不会出错的,如果出错的话可能是因为安装别的第三方库,包等,二次下载,导致 。

- 有俩个版本的numpy,系统不知应用哪个版本所以会出错

- 卸载重装(pycharm,conda都要卸载)

查看nump版本代码:

import numpy

print(numpy.__path__)


print(numpy.version.version)

如果运行其他文件,提示numpy错误,可能是numpy版本低的问题。 

pip uninstall numpy,确保完全卸载numpy,再pip install -U numpy

numpy进行指定版本(假如指定1.14.5版本)

Pip install -U numpy==1.14.5 -i

遇到的问题及解决

问题一:

D:\Anaconda\envs\deepface\python.exe F:/EmotionProjects/Smile_Detector-master/numpybanben.py

D:\Anaconda\envs\deepface\lib\site-packages\numpy\__init__.py:148: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see GitHub - IntelPython/mkl-service: Python hooks for Intel(R) Math Kernel Library runtime control settings. from . import _distributor_init

Traceback (most recent call last):

File"D:\Anaconda\envs\deepface\lib\site-packages\numpy\core\__init__.py", line 22, in <module>from . import multiarrayFile"D:\Anaconda\envs\deepface\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>

 from . import overrides

File"D:\Anaconda\envs\deepface\lib\site-packages\numpy\core\overrides.py", line 7, in <module>

    from numpy.core._multiarray_umath import (

ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File"F:/EmotionProjects/Smile_Detector-master/numpybanben.py", line 1, in <module>

ImportnumpyFile"D:\Anaconda\envs\deepface\lib\site-packages\numpy\__init__.py", line 150, in <module>

    from . import core File "D:\Anaconda\envs\deepface\lib\site-packages\numpy\core\__init__.py", line 48, in <module>

    raise ImportError(msg)

ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for

many reasons, often due to issues with your setup or how NumPy was installed.

We have compiled some common reasons and troubleshooting tips at:   https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "D:\Anaconda\envs\deepface\python.exe"

  * The NumPy version is: "1.21.5"

and make sure that they are the versions you expect.

Please carefully study the documentation linked above for further help.

Original error was: DLL load failed: 找不到指定的模块。

解决办法1:

 在anaconda prompt命令窗口下是可以正常导入的,而在pycharm编译器中则会报错

pip uninstall -y numpy
Pip uninstall -y setuptools
Pip install setuptools
Pip install numpy

问题2安装dlib,提示numpy版本错误。 

解决办法2:

安装dlib时,会自动安装numpy,不会对之前版本进行覆盖,所以,要卸载一个numpy

问题3

ImportError: numpy.core.multiarray failed to import

Installing collected packages: numpy

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.y

安装收集的包:numpy

错误:pip 的依赖解析器当前不考虑所有已安装的包。 此行为是以下依赖冲突的根源。

解决办法:

Conda uninstall numpy

Pip uninstall numpy

Pip show numpy

一定要所有的numpy卸载干净了,再重新下载。

 因为是在anaconda的虚拟环境下,所以有的是通过pip下载,有的是通过conda下载,所以软件可能会冲突。

 重新安装后就好啦。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夏天|여름이다

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值