简体   繁体   English

期间出错:CREATE EXTENSION plpython3u; 在 PostgreSQL 9.6.0 上

[英]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:所以写答案是:

  • WINDIR is : C:\\Windows WINDIR是: C:\\Windows
  • pytverstr is use in makefile has a parameter to define version of python pytverstr 在 makefile 中使用有一个参数来定义 python 的版本
  • PYTHONDLL is the location of dll PYTHONDLL是dll的位置

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.

相关问题 无法“安装”plpython3u - postgresql - Can't “install” plpython3u - postgresql python venv 可以与 plpython3u 一起用于 postgresql 吗? - Can python venv be used with plpython3u for postgresql? 在 CentOS 7.2 上为 PostgreSQL 9.5 安装 plpython3u - Install plpython3u for PostgreSQL 9.5 on CentOS 7.2 PostgreSQL PL/Python 无法加载库 plpython3u - PostgreSQL PL/Python could not load library plpython3u 我正在容器内安装 plpython3u postgres 扩展。 在 psql 中,扩展名存在但也不存在。 Postgresql 14 - I'm installing the plpython3u postgres extension inside of a container. In psql, the extension exists but also doesn't exist. Postgresql 14 Docker 上的 PostgreSQL:如何在 `plpython3u` 下安装和运行 python 依赖项? - PostgreSQL on Docker: How to install and run python dependencies under `plpython3u`? 如何在windows上的postgresql 9.4上使用扩展plpython2u和python请求 - how to use extension plpython2u and python requests on postgresql 9.4 on windows 在plpython3u过程中导入Python包时“找不到模块” - “Module not found” when importing a Python package within a plpython3u procedure 在 PostgreSQL 中,`print` 的 plpython(3)u 输出到哪里去了? - In PostgreSQL, where does plpython(3)u output from `print` go? 在 postgresql 8 或 9 中安装 plpython - install plpython in postgresql 8 or 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM