python-2.7 – 不能使用scipy.stats
发布时间:2020-12-16 22:58:44 所属栏目:Python 来源:网络整理
导读:使用scipy.stats时,我得到一个错误.在导入scipy后的脚本中. AttributeError: 'module' object has no attribute 'stats' 在脚本编辑器中,我可以在输入scipy后点击统计数据.从下拉菜单中, 在python控制台中我无法从下拉菜单中选择python.stats,它不在那里. 我
使用scipy.stats时,我得到一个错误.在导入scipy后的脚本中.
AttributeError: 'module' object has no attribute 'stats' 在脚本编辑器中,我可以在输入scipy后点击统计数据.从下拉菜单中, 解决方法
扩展我的评论(有一个列出的答案).
Scipy和许多其他大型软件包一样,不会自动导入所有模块.如果我们想使用scipy的子包,那么我们需要直接导入它们. 但是,一些scipy子包加载其他scipy子包,因此例如导入scipy.stats也会导入大量其他包.但是我从不依赖它来使命名空间中的子包可用. 在许多使用scipy的软件包中,首选模式是导入子包以使其名称可用,例如: >>> from scipy import stats,optimize,interpolate >>> import scipy >>> scipy.stats Traceback (most recent call last): File "<stdin>",line 1,in <module> AttributeError: 'module' object has no attribute 'stats' >>> scipy.optimize Traceback (most recent call last): File "<stdin>",in <module> AttributeError: 'module' object has no attribute 'optimize' >>> import scipy.stats >>> scipy.optimize <module 'scipy.optimize' from 'C:Python26libsite-packagesscipyoptimize__init__.pyc'> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |