postgresql 9 plpython2.dll not found - python

I am trying to enable PL/Python2 in my postgresql database. My setup is as follows
windows 7 64-bit
postgresql 9.2 64-bit
In the \lib folder i have plpython3.dll but no plpython2.dll which I need as a function I need to use was written in Python2.
I found a plpython2.dll on another forum but it was a 32-bit version (I used dependency walker to test what the dll required)
I have since tried postgresql 9.0 which only has plpython.dll (which when I follow these instructions Postgres database crash when installing plpython) and then I thried postgresql 9.1 and the plpython3.dll appeared.
In the documentation it states that "Users of binary packages might find PL/Python in a separate subpackage." But I cannot find any anywhere.
I have the correct Python in my PATH environment variable and have even copied the python26.dll into the \lib folder.
Does anyone know where I can find the plpython2.dll?
thanks

There is extensive discussion at http://forums.enterprisedb.com/posts/list/2878.page
I am not sure I would try the unverified DLL download attached to one post, and certainly not on a production server. My sense from reading the link is that pl/python2 is NOT SUPPORTED on Windows PostgreSQL 9.x because these are built against Python 3.x
I could be missing something however.

Related

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.
I copied plpython3.dll to C:/Program Files/PostgreSQL/9.6/lib/
The in PostgreSQL I try running this command: 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.
Under this folder: C:\Program Files\PostgreSQL\9.6\share\extension there are plpython3u files.
How can I get PostgreSQL to recognize this Python 3 extension?
Thanks!
Copy the python34.dll file to c:\windows\system32 and name the copy python33.dll
The create language plpython3u should then work without a problem.
Exactly the same situation I faced with Postgres 9.6 Windows 10.
PL/Python3U would not get through.
Worked around it:
Installed Python34 64bit Windows 10 version.
Copied Python34.dll to c:\windows\system32 as Python33.dll and it worked.
The information is in Makefile of source installation package
We need libpython as a shared library. In Python >=2.5, configure asks Python directly. 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.
for python windows:
ifeq ($(PORTNAME), win32)
pytverstr=$(subst .,,${python_version})
PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
So the write answer is:
WINDIR is : C:\Windows
pytverstr is use in makefile has a parameter to define version of python
PYTHONDLL is the location of 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)
With Notepad++ and search PyUnicode_AsUTF8String
the python dll version is visible in last word (in my case python33.dll)
check your installation to choice the good installer of python
SELECT version();
PostgreSQL 9.4.15, compiled by Visual C++ build 1800, 64-bit
So I need install Python 33 in 64bit
edit 2020-10-02
There is also all of these informations in doc of binary ..pgsql\doc\installation-notes.html look at title Procedural Languages
edit 2021-06-11
After install the good version of Python on your system you need copy it to 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. 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. You can ask EDB for this information.
plpython3.dll in the official package is built against python 3.3, not python 3.4. What it expect is python33.dll in system32 folder. You need to install python 3.3 for your system.
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. 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. 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.
Try version python-3.4.0.amd64 for windows 64bit or other versions from this Python 3.4.0 downloads Link
Environment variables to add:
C:\Python34\Scripts
C:\Python34\

How to install PL/Python on PostgreSQL 9.3 x64 Windows 7?

I have tried to install the PL/Python v2.x language inside PostgreSQL on my database running the query:
CREATE EXTENSION plpythonu;
(I got this from http://www.postgresql.org/docs/9.3/static/plpython.html)
But I'm getting this error:
ERRO: não pôde acessar arquivo "$libdir/plpython2": No such file or directory
********** Error **********
ERRO: não pôde acessar arquivo "$libdir/plpython2": No such file or directory
SQL state: 58P01
How to install this in an automated way? I need to install it on many computers.
Typically this error message is a misleading one emitted by the Windows API LoadLibrary call. What it actually means is closer to:
Error when loading plpython2.dll: Cannot find dependency DLL python27.dll on PATH
but instead Windows just acts like it is plpython2.dll its self that could not be loaded.
You can tell if this is the issue by checking the lib directory of your PostgreSQL install for a plpython2.dll. If it's there, but you get this error, then it's a missing Python runtime. If there's no plpython2.dll at all then your PostgreSQL install is missing plpython2, something I'm raising with the packaging team.
If you have plpython2.dll but it won't load, you need to install the Python runtime that matches the PostgreSQL version. It must be the same Python major version as was used to compile PostgreSQL, e.g. if Python 2.7 was used to compile PostgreSQL, Python 2.6 won't work to run plpython.
It'd be nice if installing the required runtime was automated via the installer, but at present it isn't. It's also not properly documented, which I'll take up with the packaging team The correct runtime to install is now documented in doc\installation-notes.html inside the install directory, which you can also get to via PostgresSQL 9.3 -> Documentation -> Installation Notes in the Start menu.
For older relases that lack this information in their "installation notes" file, if you're not sure what version of Python is required you can use depends.exe (dependency walker) to see which Python DLL it's linked to. You need the same architecture of Python too - if you're installing 64-bit PostgreSQL you need 64-bit Python, etc.
The PostgreSQL 9.3 packages require Python 27. So go download Python 2.7 from http://python.org/ (not ActiveState, they aren't necessarily compatible). Make sure Python is added to the PATH by the installer (it's an option when you run the installer). Then re-try after re-starting PostgreSQL.
You can automate installation of Python with:
start /wait msiexec /i python-2.7.3.amd64.msi /qb /passive TARGETDIR=%SystemDrive%\Python27_x64 ALLUSERS=1
where python-2.7.3.amd64.msi is the filename of the Python binary you installed, and you're installing the 64-bit version to C:\Python27_x64. Adjust as desired.
In my case it worked just installing Python 3.3. Previously I had 2.7 and 3.4, but non of them was the want it wanted.
I have PostgreSQL 9.4 x64 running on Windows 7

Python 2.7 32-bit install on Win 7: No registry keys?

I have downloaded the Python 2.7.2 Windows x86 32-bit MSI from python.org and installed it on a 64-bit Windows 7 system. Everything works (at least the command-line interpreter starts and runs), but the install process does not create any Python entries under HKEY_LOCAL_MACHINE/SOFTWARE in the Windows registry.
Various blogs refer to problems created by incomplete Python registry entries when attempting to configure third-party libraries, but I have not found a description of the complete absence of a Python entry in the registry.
I plan to use Python only with the Google Apps Engine SDK and (hopefully) django-nonrel for some fairly simple Google Apps projects. The absence of a Python registry key may not even be an issue for me, but the Django setup docs assume its existence and suggest adding path information to it as a way to populate Python's sys.path list.
Anyone else run into this? Is an additional install step necessary to create the key? Should I manually create it using regedit? Is it even needed, or can the PATH and/or PYTHONPATH environment variables be used for everything instead?
32-bit applications installed on 64-bit OSes store their registry values in:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. If you look there, you should see the settings you are looking for.

Integrating MySQL with Python in Windows

I am finding it difficult to use MySQL with Python in my windows system.
I am currently using Python 2.6. I have tried to compile MySQL-python-1.2.3b1 (which is supposed to work for Python 2.6 ?) source code using the provided setup scripts. The setup script runs and it doesn't report any error but it doesn't generate _mysql module.
I have also tried setting up MySQL for Python 2.5 with out success. The problem with using 2.5 is that Python 2.5 is compiled with visual studio 2003 (I installed it using the provided binaries). I have visual studio 2005 on my windows system. Hence setuptools fails to generate _mysql module.
Any help ?
Download page for python-mysqldb. The page includes binaries for 32 and 64 bit versions of for Python 2.5, 2.6 and 2.7.
There's also discussion on getting rid of the deprecation warning.
UPDATE: This is an old answer. Currently, I would recommend using PyMySQL. It's pure python, so it supports all OSes equally, it's almost a drop-in replacement for mysqldb, and it also works with python 3. The best way to install it is using pip. You can install it from here (more instructions here), and then run:
pip install pymysql
This may read like your grandpa givin advice, but all answers here did not mention the best way: go nd install ActivePython instead of python.org windows binaries. I was really wondering for a long time why Python development on windows was such a pita - until I installed activestate python. I am not affiliated with them. It is just the plain truth. Write it on every wall: Python development on Windows = ActiveState!
you then just pypm install mysql-python and everything works smoothly. no compile orgy. no strange errors. no terror. Just start coding and doing real work after five minutes.
This is the only way to go on windows. Really.
As Python newbie learning the Python ecosystem I've just completed this.
Install setuptools instructions
Install MySQL 5.1. Download the 97.6MB MSI from here You can't use the essentials version because it doesnt contain the C libraries.
Be sure to select a custom install, and mark the development tools / libraries for installation as that is not done by default. This is needed to get the C header files.
You can verify you have done this correctly by looking in your install directory for a folder named "include". E.G C:\Program Files\MySQL\MySQL Server 5.1\include. It should have a whole bunch of .h files.
Install Microsoft Visual Studio C++ Express 2008 from here This is needed to get a C compiler.
Open up a command line as administrator (right click on the Cmd shortcut and then "run as administrator". Be sure to open a fresh window after you have installed those things or your path won't be updated and the install will still fail.
From the command prompt:
easy_install -b C:\temp\sometempdir mysql-python
That will fail - which is OK.
Now open site.cfg in your temp directory C:\temp\sometempdir and edit the "registry_key" setting to:
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
now CD into your temp dir and:
python setup.py clean
python setup.py install
You should be ready to rock!
Here is a super simple script to start off learning the Python DB API for you - if you need it.
I found a location were one person had successfully built mysql for python2.6, sharing the link, http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
...you might see a warning while import MySQLdb which is fine and that won’t hurt anything,
C:\Python26\lib\site-packages\MySQLdb__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
What about pymysql? It's pure Python, and I've used it on Windows with considerable success, bypassing the difficulties of compiling and installing mysql-python.
You're not the only person having problems with Python 2.6 and MySQL (http://blog.contriving.net/2009/03/04/using-python-26-mysql-on-windows-is-nearly-impossible/). Here's an explanation how it should run under Python 2.5 http://i.justrealized.com/2008/04/08/how-to-install-python-and-django-in-windows-vista/
Good luck
The precompiled binaries on http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python is just worked for me.
Open MySQL_python-1.2.5-cp27-none-win_amd64.whl file with zip
extractor program.
Copy the contents to
C:\Python27\Lib\site-packages\
On Python 3.4 I've installed mysqlclient from http://www.lfd.uci.edu/~gohlke/pythonlibs/ with pip install mysqlclient and it's working.
You can try to use myPySQL. It's really easy to use; no compilation for windows, and even if you need to compile it for any reason, you only need Python and Visual C installed (not mysql).
http://code.google.com/p/mypysql/
Good luck
There are Windows binaries for MySQL-Python (2.4 & 2.5) available on Sourceforge. Have you tried those?
Because I am running python in a (pylons/pyramid) virtualenv, I could not run the binary installers (helpfully) linked to previously.
I had problems following the steps with Willie's answer, but I determined that the problem is (probably) that I am running windows 7 x64 install, which puts the registry key for mysql in a slightly different location, specifically in my case (note: I am running version 5.5) in: "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MySQL AB\MySQL Server 5.5".
HOWEVER, "HKEY_LOCAL_MACHINE\" cannot be included in the path or it will fail.
Also, I had to do a restart between steps 3 and 4.
After working through all of this, IMO it would have been smarter to run the entire python dev environment from cygwin.
If you are looking for Python 3.2 this seems the best solution I found so far
for Python 2.4 - 3.2 PyMySQL
for Python 2.3 - 2.6 MySQL for Python
Source: http://wiki.python.org/moin/MySQL
You might want to also consider making use of Cygwin, it has mysql python libraries in the repository.
You can also use pyodbc with the MySQL Connector/ODBC to use MySQL on Windows. Unixodbc is also available to make the code compatible on Linux. Pyodbc uses the standard Python DB API 2.0 so if you stick with that switching between MySQL/PostgreSQL/SQLite/ODBC/JDBC drivers etc. should be relatively painless.
upvoted itsadok's answer because it led me to the installation for python 2.7 as well, which is located here: http://www.codegood.com/archives/129
Got sick of the installation troubles with MySQLdb and tried pymysql instead.
Easy setup;
git clone https://github.com/petehunt/PyMySQL.git
python setup.py install
And APIs are pretty much the same.

Problem compiling MySQLdb for Python 2.6 on Win32

I'm using Django and Python 2.6, and I want to grow my application using a MySQL backend. Problem is that there isn't a win32 package for MySQLdb on Python 2.6.
Now I'm no hacker, but I thought I might compile it myself using MSVC++9 Express. But I run into a problem that the compiler quickly can't find config_win.h, which I assume is a header file for MySQL so that the MySQLdb package can know what calls it can make into MySQL.
Am I right? And if so, where do I get the header files for MySQL?
Thanks all! I found that I hadn't installed the developer components in MySQL. Once that was done the problem was solved and I easily compiled the MySQLdb for Python 2.6.
I've made the package available at my site.
I think that the header files are shipped with MySQL, just make sure you check the appropriate options when installing (I think that sources and headers are under "developer components" in the installation dialog).
Have you considered using a pre-built stack with Python, MySQL, Apache, etc.?
For example: http://bitnami.org/stack/djangostack
Also see this post on the mysql-python blog: MySQL-python-1.2.3 beta 2 released - dated March 2009. MySQLdb for Python 2.6 is still a work in progress...

Categories