Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:ModuleNotFoundError:没有名为';统计数据';_Python_Python 3.x_Windows_Numpy_Scipy - Fatal编程技术网

Python:ModuleNotFoundError:没有名为';统计数据';

Python:ModuleNotFoundError:没有名为';统计数据';,python,python-3.x,windows,numpy,scipy,Python,Python 3.x,Windows,Numpy,Scipy,我正在尝试运行一个脚本,该脚本要求SciPy能够使用stats模块。当我尝试运行此脚本时,我得到以下结果: $python ./myScript.py 100 someFile.json Traceback (most recent call last): File "./myScript.py", line 12, in <module> from sampler import * File "C:\myProject\python\l

我正在尝试运行一个脚本,该脚本要求SciPy能够使用stats模块。当我尝试运行此脚本时,我得到以下结果:

$python ./myScript.py 100 someFile.json
Traceback (most recent call last):
  File "./myScript.py", line 12, in <module>
    from sampler import *
  File "C:\myProject\python\lib\anotherScript.py", line 28, in <module>
    from stats import Histogram
ModuleNotFoundError: No module named 'stats'
我在某个地方读到,我需要先安装Numpy,所以我使用了它,然后安装了SciPy,两个都安装成功

我在Stack Overflow(如强制重新安装Numpy和SciPy)尝试了其他答案中提供的答案,但没有成功。我还做了以下测试:

$ python
Python 3.8.4 (tags/v3.8.4:dfa645a, Jul 13 2020, 16:46:45) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> scipy.version.full_version
'1.5.1'
>>>
>>> from scipy import stats
>>> from stats import Histogram
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'stats'
>>>
>>> from stats import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'stats'
>>>
$python
win32上的Python 3.8.4(tags/v3.8.4:dfa645a,2020年7月13日,16:46:45)[MSC v.1924 64位(AMD64)]
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>进口西皮
>>>scipy.version.full\u版本
'1.5.1'
>>>
>>>从scipy导入统计信息
>>>从统计数据导入直方图
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ModuleNotFoundError:没有名为“stats”的模块
>>>
>>>从统计数据导入*
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ModuleNotFoundError:没有名为“stats”的模块
>>>

下一步该怎么办?

scipy.stats.histogram
在最新版本中已被弃用。 您只需将其导入为:

from scipy import stats
stats.rv_histogram()

下面是scipy文档中的示例

from scipy import stats
import numpy as np
data = stats.norm.rvs(size=100000, loc=0, scale=1.5, random_state=123)
hist = np.histogram(data, bins=100)
hist_dist = stats.rv_histogram(hist)
结果:

hist_dist.pdf(1.0)
0.20538577847618705
hist_dist.cdf(2.0)
0.90818568543056499

您可以在此处找到文档:

来自scipy导入统计信息
已加载统计信息模块。你所需要做的就是参考统计图,这就是我需要的。谢谢你的帮助。问候语。
from scipy import stats
import numpy as np
data = stats.norm.rvs(size=100000, loc=0, scale=1.5, random_state=123)
hist = np.histogram(data, bins=100)
hist_dist = stats.rv_histogram(hist)
hist_dist.pdf(1.0)
0.20538577847618705
hist_dist.cdf(2.0)
0.90818568543056499