【问题标题】:PL/Python with AnacondaPL/Python 与 Anaconda
【发布时间】:2015-10-23 15:52:51
【问题描述】:

我在 Ubuntu 上安装了 Anaconda,并希望在 PL/Python 中使用其中的一些模块。但是,每次我调用 scipy 时,都会出现 ImportError: No module 名为 scipy.stats 的错误。

如何让 Anaconda 与 PL/Python 一起工作?

更新:以下是代码和错误

创建或替换函数 hdi_bars( 分子整数, 分母整数) 返回 SETOF 双精度 [] AS $身体$

从 scipy.stats 导入测试版 将 numpy 导入为 np 从 scipy.stats 导入测试版 将 numpy 导入为 np

$身体$ 语言 plpythonu 易失性 费用 100 行数 1000; ALTER FUNCTION hdi_bars(整数,整数) postgres 的所有者;

错误: 错误:ImportError:没有名为 scipy.stats 的模块 上下文:回溯(最近一次通话最后一次): PL/Python 函数“hdi_bars”,第 5 行,在 从 scipy.stats 导入测试版 PL/Python 函数“hdi_bars”

**********错误**********

错误:ImportError:没有名为 scipy.stats 的模块 SQL状态:XX000 上下文:回溯(最近一次通话最后一次): PL/Python 函数“hdi_bars”,第 5 行,在 从 scipy.stats 导入测试版 PL/Python 函数“hdi_bars”

【问题讨论】:

  • 请添加您正在使用的代码的简短示例和完整的错误回溯。
  • 很抱歉。我更新了我的帖子以包含一些代码和我从 PostgreSQL 得到的错误。
  • 当你这样做时,你确定你运行的是 anaconda 而不是系统 python 吗? (从您的脚本中,您可以通过import sys; print(sys.executable) 进行验证。)

标签: python postgresql anaconda plpython


【解决方案1】:

基于Postgres installation/configuration docs,有一个环境变量PYTHON,可以设置为你想要的Python可执行文件的完整路径。否则,默认的 --with-python 行为将查找系统 Python,很可能在 /usr/bin/python 或其他操作系统的类似标准位置。

This question and answer 似乎确认要更改它,您需要从源代码重建 Postgres。

【讨论】:

    猜你喜欢
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 2017-06-25
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 2018-01-07
    • 2014-10-17
    相关资源
    最近更新 更多