[英]Error during: CREATE EXTENSION plpython3u; on PostgreSQL 9.6.0
I have installed PostgreSQL Server 9.6.0 and Python 3.4.2 on Windows 2012 R2 Server.我已经在 Windows 2012 R2 Server 上安装了 PostgreSQL Server 9.6.0 和 Python 3.4.2。
I copied plpython3.dll to C:/Program Files/PostgreSQL/9.6/lib/我将plpython3.dll复制到C:/Program Files/PostgreSQL/9.6/lib/
The in PostgreSQL I try running this command: CREATE EXTENSION plpython3u;在 PostgreSQL 我尝试运行这个命令: CREATE EXTENSION plpython3u;
And I receive this message:我收到这条消息:
ERROR: could not load library "C:/Program Files/PostgreSQL/9.6/lib/plpython3.dll": The specified module could not be found.错误:无法加载库“C:/Program Files/PostgreSQL/9.6/lib/plpython3.dll”:找不到指定的模块。
Under this folder: C:\\Program Files\\PostgreSQL\\9.6\\share\\extension there are plpython3u files.在这个文件夹下: C:\\Program Files\\PostgreSQL\\9.6\\share\\extension有 plpython3u 文件。
How can I get PostgreSQL to recognize this Python 3 extension?如何让 PostgreSQL 识别这个 Python 3 扩展?
Thanks!谢谢!
Copy the python34.dll file to c:\\windows\\system32 and name the copy python33.dll将 python34.dll 文件复制到 c:\\windows\\system32 并将副本命名为 python33.dll
The create language plpython3u should then work without a problem.然后创建语言 plpython3u 应该可以正常工作。
Exactly the same situation I faced with Postgres 9.6 Windows 10. PL/Python3U would not get through.与我在 Postgres 9.6 Windows 10 上遇到的情况完全相同。PL/Python3U 无法通过。
Worked around it:解决它:
Installed Python34 64bit Windows 10 version.安装了 Python34 64 位 Windows 10 版本。 Copied Python34.dll to c:\\windows\\system32 as Python33.dll and it worked.
将 Python34.dll 作为 Python33.dll 复制到 c:\\windows\\system32 并且它起作用了。
The information is in Makefile of source installation package信息在源码安装包的Makefile中
We need libpython as a shared library.我们需要 libpython 作为共享库。 In Python >=2.5, configure asks Python directly.
在 Python >=2.5 中,configure 直接询问 Python。 But because this has been broken in Debian for a long time ( http://bugs.debian.org/695979 ), and to support older Python versions, we see if there is a file that is named like a shared library as a fallback.
但是因为这在 Debian 中已经被打破了很长时间( http://bugs.debian.org/695979 ),并且为了支持旧的 Python 版本,我们看看是否有一个像共享库一样命名的文件作为后备.
for python windows:对于 python 窗口:
ifeq ($(PORTNAME), win32)
pytverstr=$(subst .,,${python_version})
PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
So the write answer is:所以写答案是:
To check version of my installation, I open plpython3.dll located in C:\\Program Files\\PostgreSQL\\9.4\\lib (change path with your environnement)要检查我的安装版本,我打开位于C:\\Program Files\\PostgreSQL\\9.4\\lib的 plpython3.dll(根据您的环境更改路径)
With Notepad++ and search PyUnicode_AsUTF8String the python dll version is visible in last word (in my case python33.dll)使用 Notepad++ 并搜索PyUnicode_AsUTF8String ,python dll 版本在最后一个字中可见(在我的情况下为 python33.dll)
check your installation to choice the good installer of python检查您的安装以选择好的python安装程序
SELECT version();
PostgreSQL 9.4.15, compiled by Visual C++ build 1800, 64-bit PostgreSQL 9.4.15,由 Visual C++ build 1800 编译, 64 位
So I need install Python 33 in 64bit所以我需要在 64 位安装 Python 33
edit 2020-10-02编辑 2020-10-02
There is also all of these informations in doc of binary ..pgsql\\doc\\installation-notes.html look at title Procedural Languages在二进制..pgsql\\doc\\installation-notes.html 的doc 中也有所有这些信息,看标题Procedural Languages
edit 2021-06-11编辑 2021-06-11
After install the good version of Python on your system you need copy it to C:\\Windows\\System32
在您的系统上安装好的 Python 版本后,您需要将其复制到
C:\\Windows\\System32
Replacing the version of python with an old name is not a good solution because you can have librairie it not work with this version.用旧名称替换 python 版本不是一个好的解决方案,因为您可以让 librairie 它不适用于此版本。 Do that if you know risks.
如果您知道风险,请这样做。 So if you want a newest version of python for plpython, compile it or check edb compilation to check if it contains what you need.
因此,如果您想要 plpython 的最新版本的 python,请编译它或检查 edb 编译以检查它是否包含您需要的内容。 You can ask EDB for this information.
你可以向教育局索取这些资料。
plpython3.dll in the official package is built against python 3.3, not python 3.4.官方包中的 plpython3.dll 是针对 python 3.3 构建的,而不是 python 3.4。 What it expect is python33.dll in system32 folder.
它期望的是 system32 文件夹中的 python33.dll。 You need to install python 3.3 for your system.
您需要为您的系统安装 python 3.3。
Since py33 has been phased out, you may soon get frustrated, due to lack of pre-built binary package, lxml, pyzmq etc all needs to be built from source.由于 py33 已被淘汰,您可能很快就会感到沮丧,因为缺少预构建的二进制包,lxml、pyzmq 等都需要从源代码构建。 If you need any binary module, make sure you have a correctly set up compiler.
如果您需要任何二进制模块,请确保您有一个正确设置的编译器。
This may be helpful, I have struggled a lot with this.这可能会有所帮助,我为此苦苦挣扎。 For me only worked when I installed the right version of python and added paths to environment variables.
对我来说,只有当我安装了正确版本的 python 并添加了环境变量的路径时才有效。 I am not sure if python 3.4.0 would be the right version for PostgreSQL Server 9.6.0 but it worked fine with PostgreSQL Server 10.0 .
我不确定 python 3.4.0 是否是PostgreSQL Server 9.6.0的正确版本,但它与PostgreSQL Server 10.0一起工作得很好。
Try version python-3.4.0.amd64 for windows 64bit or other versions from this Python 3.4.0 downloads Link从这个Python 3.4.0 下载链接尝试适用于 windows 64 位或其他版本的 python-3.4.0.amd64 版本
Environment variables to add:要添加的环境变量:
C:\\Python34\\Scripts C:\\Python34\\ C:\\Python34\\Scripts C:\\Python34\\
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.