from sklearn import datasets运行错误:ImportError: DLL load failed: 找不到指定的程序------解决办法
- 在运行集成学习的多数投票分类代码时,出现错误
from sklearn import datasets
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import VotingClassifier
iris = datasets.load_iris()
X, y = iris.data[:, 1:3], iris.target
clf1 = LogisticRegression(solver='lbfgs', multi_class='multinomial', random_state=1)
clf2 = RandomForestClassifier(n_estimators=50, random_state=1)
clf3 = GaussianNB()
ensemble_clf = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('gnb',clf3)], voting='hard')
for clf, label in zip([clf1, clf2, clf3, ensemble_clf], ['Logistic Regression', 'Random Forest', 'naive Bayes', 'Ensemble']):
scores = cross_val_score(clf, X, y, cv = 5, scoring='accuracy')
# scoring里面的有效参数有['accuracy', 'adjusted_rand_score', 'average_precision', 'f1', 'f1_macro', 'f1_micro', 'f1_samples',
# 'f1_weighted', 'neg_log_loss', 'neg_mean_absolute_error', 'neg_mean_squared_error', 'neg_median_absolute_error',
# 'precision', 'precision_macro', 'precision_micro', 'precision_samples', 'precision_weighted',
# 'r2', 'recall', 'recall_macro', 'recall_micro', 'recall_samples', 'recall_weighted', 'roc_auc']
print('Accuracy: %0.2f (+/- %0.2f) ------- %s' %(scores.mean(), scores.std(), label))
- 运行结果
- 出错原因
如果遇到错误:ImportError: DLL load failed: 找不到指定的模块
出现错误原因:安装包的来源问题,也可以理解为包版本兼容问题,有的包使用官方出版,有的包使用whl文件安装
解决方案:将所有包都统一来源,要么全部使用官方出版的包,要么全部使用whl里面的包,问题就解决了
解决方法
- (1)先卸载原始版本Scikit-Learn,Numpy和Scipy
pip uninstall scikit-learn
pip uninstall numpy
pip uninstall scipy
- (2) 安装自己电脑对应的版本
whl包下载:https://www.lfd.uci.edu/~gohlke/pythonlibs/# 下载需要的scikit-learn,numpy,scipy三个whl文件
然后依次安装numpy,scipy和scikit-learn的轮子
pip install numpy-1.16.5+mkl-cp36-cp36m-win_amd64.whl
pip install scipy-1.3.3-cp36-cp36m-win_amd64.whl
pip install scikit_learn-0.21.3-cp36-cp36m-win_amd64.whl
- 重新运行上述代码 成功运行

参考资料1:https://www.cnblogs.com/hamish26/p/10985139.html
参考资料2:https://blog.csdn.net/a593651986/article/details/72178463
from sklearn import datasets运行错误:ImportError: DLL load failed: 找不到指定的程序------解决办法的更多相关文章
- python中导入sklearn中模块提示ImportError: DLL load failed: 找不到指定的程序。
python版本:3.7 平台:windows 10 集成环境:Anaconda3.7 64位 在jupyter notebook中导入sklearn的相关模块提示ImportError: DLL l ...
- Scrapy模块使用出错,出现builtins.ImportError: DLL load failed: 找不到指定的程序
问题描述:初次学习scrapy,使用scrapy官方文档创建爬虫项目出错, 出现builtins.ImportError: DLL load failed: 找不到指定的程序, ImportError ...
- 关于python 3.x import matplotlib as plt ImportError: DLL load failed: 找不到指定的模块
windows 10下使用conda update --all更新过后,就出现这样的问题了,各种包不能用了,然后在stackoverflow上搜到有人也遇到相同的问题,并通过其中的回答找到了原因,这里 ...
- 问题解决:import paddle.fluid出错:DLL load failed: 找不到指定的模块
问题描述: 使用Pycharm编程,导入paddlepaddle库出错.即:import paddle.fluid出错:DLL load failed: 找不到指定的模块 解决方法: 补上缺失的DLL ...
- 运行Scrapy项目提示“import win32api ImportError: DLL load failed: 找不到指定的模块。”
安装完成Scrapy时候,终端导入Scrapy时候,发现没有任何报错,但是在运行Scrapy的项目的时候提示“import win32api ImportError: DLL load failed: ...
- ImportError: DLL load failed: 找不到指定的模块;ImportError: numpy.core.multiarray failed to import 报错解决
python程序运行出错,出错的两行主要信息如下: ImportError: DLL load failed: 找不到指定的模块 ImportError: numpy.core.multiarray ...
- 终于解决了python 3.x import cv2 “ImportError: DLL load failed: 找不到指定的模块” 及“pycharm关于cv2没有代码提示”的问题
终于解决了python 3.x import cv2 “ImportError: DLL load failed: 找不到指定的模块” 及“pycharm关于cv2没有代码提示”的问题 参考 :h ...
- from .cv2 import * ImportError: DLL load failed: 找不到指定的模块。 >>>
from .cv2 import * ImportError: DLL load failed: 找不到指定的模块. >>> 昨天看项目的时候遇到这个问题,折腾到深夜,网上的各种方法 ...
- from _sqlite3 import * ImportError: DLL load failed: 找不到指定的模块。
*Error creating Django application: Error on python side. Exit code: 1, err: Traceback (most recent ...
随机推荐
- Tensorflow API 学习(1)-tf.slice()
slice()函数原型为: tf.slice(input_, begin, size, name=None) 函数有4个参数: 1,input_ :图片的矩阵输入格式. 2,begin :开始截取的位 ...
- 【三】Django模版的使用
作为Web框架,Django提供了模板,可以很便利的动态生成HTML 模版系统致力于表达外观,而不是程序逻辑 模板的设计实现了业务逻辑(view)与显示内容(template)的分离,一个视图可以使用 ...
- Android 组件化之路 资源冲突问题
比如我现在有3个模块:app模块,user模块,me模块,其中app模块依赖user模块和me模块. 然后我在user模块和me模块的strings.xml中都定义了greet字符串: // user ...
- celery开发中踩的坑
celery开发中踩的坑 celery连接redis 当使用redis做broker,redis连接需要密码时: BROKER_URL='redis://:xxxxx@127.0.0.1:6379/0 ...
- 【转】rsa公钥和私钥的生成
转:https://www.cnblogs.com/zengsf/p/10136886.html 在liunx环境中 openssl 然后生成私钥: genrsa -out app_private_k ...
- java数据结构1--数组、排序和Arrays工具类
数组:Array 数组的定义 数组的内存结构 数组定义常见问题 数组常见操作 Java参数传递问题--值传递 二维数组 1.数组概念 同一种类型数据的集合,可以是基本数据类型,也可以是引用数据类型. ...
- Gym-100923H-Por Costel and the Match(带权并查集)
链接: https://vjudge.net/problem/Gym-100923H 题意: Oberyn Martell and Gregor Clegane are dueling in a tr ...
- pyqt5--QTDesigner--安装与配置
安装: 安装PyQt5-tools 文件--->设置---> ---> 安装之后在 安装目录\Lib\site-packages\pyqt5_tools 找到 designer.e ...
- UVALive 3211 : Now or later 【2-SAT】
题目链接 题意及题解参见lrj训练指南 #include<bits/stdc++.h> using namespace std; ; struct TwoSAT { int n; vect ...
- Java基础——面试、笔试
网址来源: http://www.nowcoder.com/discuss/5949?type=0&order=0&pos=4&page=2 参考资料:(java方面的一些面试 ...



