简体   繁体   English

从..utils.fixes导入rankdata ImportError:无法导入名称“ rankdata” MongoDB

[英]from ..utils.fixes import rankdata ImportError: cannot import name 'rankdata' MongoDB

I am trying to run Skikit learn through Spyder on Anaconda 我正在尝试在Anaconda上通过Spyder运行Skikit学习

C:\Anaconda3>conda --version
conda 4.3.4
C:\Anaconda3>python --version
Python 3.5.2 :: Anaconda 4.0.0 (64-bit)
Spyder 2.3.8

I try to do the following: 我尝试执行以下操作:

print("Scikit-Learn", sklearn.__version__)
NameError: name 'sklearn' is not defined
from sklearn.model_selection import *
from ..utils.fixes import rankdata
ImportError: cannot import name 'rankdata'
Errors

Any idea why this error is coming as in Anaconda it shows the package as present but when I run through Spyder it gives the above error. 知道为什么会出现此错误,就像在Anaconda中一样,它显示了该软件包的存在,但是当我运行Spyder时,它给出了以上错误。

As you are using anaconda try: 当您使用水蟒时,请尝试:

conda update scikit-learn

Conda will try to handle de dependences and it may update other packages. Conda将尝试处理依赖关系,并且可能会更新其他软件包。

If this does not work, in the file fixes.py located in <Anaconda_basedir>\\lib\\python3.5\\site-packages\\sklearn\\utils there is a line if sp_version < (0,13, 0): which conditions the import of rankdata if the version of scipy is lower than 0.13.0. 如果这不起作用,则位于<Anaconda_basedir>\\lib\\python3.5\\site-packages\\sklearn\\utils中的if sp_version < (0,13, 0): )中有一行if sp_version < (0,13, 0):这将限制导入如果rankdata的版本低于0.13.0,则为rankdata。

For som reason, if the version is > 0.13.0 it should use the rankdata from scipy.stats . 出于某种原因,如果版本> 0.13.0,则应使用rankdatascipy.stats But, at least in my case it wasn't, what I did was to add a and False so it gets the rankdata from scipy . 但是,至少在我的情况不是这样,我所做的就是添加and False因此它的rankdatascipy

The final line is: 最后一行是:

...
if sp_version < (0, 13, 0) and False:
    def rankdata(a, method='average'):
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ImportError:无法从“sklearn.utils.fixes”导入名称“_argmax” - ImportError: cannot import name '_argmax' from 'sklearn.utils.fixes' 由于错误,无法导入 SMOTE &lt;<ImportError: cannot import name 'lobpcg' from 'sklearn.utils.fixes' > &gt; - Unable to import SMOTE due to error <<ImportError: cannot import name 'lobpcg' from 'sklearn.utils.fixes' >> 导入错误:无法从“sklearn.utils.fixes”导入名称“_astype_copy_false” - ImportError: cannot import name '_astype_copy_false' from 'sklearn.utils.fixes' 无法从“sklearn.utils.fixes”导入名称“延迟” - cannot import name 'delayed' from 'sklearn.utils.fixes' ImportError:无法从“gensim.utils”导入名称“已弃用” - ImportError: cannot import name 'deprecated' from 'gensim.utils 导入错误:无法导入名称 np_utils - ImportError: cannot import name np_utils Python ImportError:无法导入名称实用程序 - Python ImportError: cannot import name utils 来自django.db import utils ImportError无法导入名称utils? - from django.db import utils ImportError cannot import name utils? 从django.db导入utils ImportError:无法导入名称utils错误 - from django.db import utils ImportError: cannot import name utils error 无法从“sklearn.utils.fixes”导入名称“parse_version” - cannot import name 'parse_version' from 'sklearn.utils.fixes'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM