无法“安装"plpython3u - postgresql [英] Can't "install" plpython3u - postgresql
问题描述
我正在尝试在 postgresql 中使用 python 语言.像这样:
create or replace function test(_a integer) 返回整数作为 $$如果 _a%2==0:返回偶数"elif _a%3==0:返回3 的倍数"别的:返回_a$$ 语言 plpython3u
但是当我运行这个时,我得到这个错误:
错误:语言plpython3u"不存在提示:使用 CREATE EXTENSION 将语言加载到数据库中.SQL 状态:42704
然后,我尝试通过执行来创建python语言的扩展:
创建扩展plpython3u
告诉我以下错误:
错误:无法加载库C:/Program Files/PostgreSQL/12/lib/plpython3.dll":找不到指定的模块.SQL 状态:58P01
我检查了 plpython3.dll
文件是否存在.然后我阅读了一些关于通过从源代码编译 postgres 并添加 --with python
来修改 postgresql configure
文件的内容(我发现了一些这样的
I'm trying to use python language in postgresql. Something like this:
create or replace function test(_a integer) returns integer as $$
if _a%2==0:
return 'even'
elif _a%3==0:
return 'mult of 3'
else:
return _a
$$ language plpython3u
But when I run this, I get this error:
ERROR: language "plpython3u" does not exist
HINT: Use CREATE EXTENSION to load the language into the database.
SQL state: 42704
Then, I tried to create the extension of the python language by executing:
create extension plpython3u
Which tells me the following error:
ERROR: could not load library "C:/Program Files/PostgreSQL/12/lib/plpython3.dll": The specified module could not be found.
SQL state: 58P01
I checked if the plpython3.dll
file is there. Then I read something about modifying the postgresql configure
file by compiling postgres from the source code and adding --with python
(I found some of this here).
My problem is that I don't know how to actually do this. My OS is windows server 2019 64 bits, python version is 3.7.4 and postgresql version is 12.2-1 (pgadmin 4.18).
How can I solve this?
Getting python to work with postgres seems to be version or versions dependent. I currently have postgres 9.6. and I had installed python 3.9. I had previously installed the extension plpython3u in postgres but time had gone by and I moved to another computer. When I tried to run a procedure based on Python, I got an error. I downloaded dependency walker, from here: https://www.opcsupport.com/s/article/How-do-I-figure-out-why-my-DLL-is-failing-Microsoft-Dependency-Walker or here: https://www.dependencywalker.com/. When I opened up the dependency walker, I dragged the plpython3.dll into the dependency walker, the .dll is located here: F:\pg96\lib. I then got the following screen -- below -- that seemed to indicate I needed to install a Python 3.7. I downloaded Python 3.7 from here: https://www.python.org/downloads/windows/. And my python procedures now worked.
这篇关于无法“安装"plpython3u - postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!