ImportError:没有名为pymc3的模块

卡拉·安德里亚·桑多瓦尔(Karla Andrea Sandoval)

我正在尝试运行以下示例:

import pymc3 as pm

from numpy import array, empty

from numpy.random import randint

__all__ = [
    'disasters_array',
    'switchpoint',
    'early_mean',
    'late_mean',
    'rate',
    'disasters']

disasters_array = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
                         3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
                         2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
                         1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
                         0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
                         3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
                         0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])


switchpoint = DiscreteUniform(
    'switchpoint',
    lower=0,
    upper=110,
    doc='Switchpoint[year]')
early_mean = Exponential('early_mean', beta=1.)
late_mean = Exponential('late_mean', beta=1.)


@deterministic(plot=False)
def rate(s=switchpoint, e=early_mean, l=late_mean):
    ''' Concatenate Poisson means '''
    out = empty(len(disasters_array))
    out[:s] = e
    out[s:] = l
    return out

disasters = Poisson('disasters', mu=rate, value=disasters_array, observed=True)

当我运行它时,它引发以下错误:ImportError:没有名为pymc3的模块

我已经用pip安装了pymc3,并且成功。我不知道为什么找不到pymc3。有人知道如何解决吗?我已经使用了几个编辑器,但是没有一个在工作。

谢谢!

米海·安德烈(Mihai Andrei)

您可能安装了多个python解释器。还是有更多的虚拟环境。

您在其中安装了pymc3,而在另一脚本中运行了脚本。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章