python - ImportError:没有名为 pymc3 的模块
问题描述
我正在尝试运行以下示例:
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: No module named pymc3
我已经用 pip 安装了 pymc3,它是成功的。不知道为什么找不到pymc3。有谁知道如何解决这个问题?我使用了几个编辑器,但没有一个工作。
谢谢!
解决方案
您可能安装了多个 python 解释器。或者有更多的虚拟环境。
您将 pymc3 安装在一个中,而您的脚本与另一个一起运行。
推荐阅读
- ios - 带有 Ipad pro IOS 13 的第 8 面墙在请求摄像头访问时循环
- javascript - 如何使用正则表达式过滤用户在 Vuetify 组合框中输入的内容以创建芯片?
- flutter - 如何在不创建无休止的 TextEditingController 的情况下保存不同的 Textfield 值
- cucumber - 使用 WebdriverIO 和 Cucumber 上传文件
- php - 带有波斯文件名的php getimagesize
- javascript - 如何使用 JavaScript 在新窗口中从主页打开功能?
- javascript - 猫鼬不居住
- javascript - React - MUI - 无法取消选择多选中的所有项目
- google-cloud-platform - 如何跟踪 Google Cloud 公共数据集的变化?
- sql - 投射后“锚点和递归部分之间的类型不匹配”