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\
Related
I'm trying to load a python extension to WinDBG, using PyKd.
.load pykd succeeds.
When I'm running !py, I get this:
failed to find python interpreter
Things I've tried:
Different versions of python
Using PyKd's dll and pyd files
.reload /f
Different symbol paths
Debugging WinDBG and PyKd, also going through the source, no success
Yes, my environment is set correctly with the Python path.
Couldn't find any mention of that problem in the web.
It had always ran smoothly on different systems and configurations I had, but on my new system I get this weird message.
Details:
Windows 10 Home, version 1607, x64
WinDBG x86, build 10.0.15063.0
Python 2.7.13, but I tried many other versions as well.
Symbols path: cache*c:\symbols;srv*https://msdl.microsoft.com/download/symbols
Dell XPS 15
guy
I installed the latest pykd too, and occur the same problem.
Then I found that I hadn't installed python 2.7 at this virtualbox.
Installing python 2.7 will work.
You have installed it.I suggest you check whether python installation path is in "path" environment variable
if you don't have this register path:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\xx\PythonPath, then you should install python-2.7(x64) with Path enabled.
I had this issue when having multiple python installations on the same machine. Managed to solve it by manually creating required registry key, as I did not want to reinstall any python versions, nor change the global path/pythonpath variables.
Note that you will need x64 python for windbgx64 and x86 python for windbgx86
Let's say you want to use python 3.7x86 installed at c:\python37_x86, and python 3.6x64 installed at c:\python36_x64
Create keys leading to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.7-32\InstallPath there, and set the (Default) to c:\python37_x86\ (the trailing backslash is important!)
Similarly, create keys leading to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.6\InstallPath there, and set the (Default) to c:\python36_x64\
Unfortunately the PYTHONPATH environment variable is still being used, and must match the referenced python version(otherwise you will encounter Fatal Python error: unable to load the file system codec . NOTE: this may only be important if one of the versions is 2.x and the other 3.x. Try making it work without this step
To circumvent the last issue I created .bat files to modify the environment and launch windbg with the correct environment.
For example for launching 32 bit windbg:
set PYTHONPATH=C:\python37_x86\Lib;[...Rest of the PYTHONPATH for this python version...]
start windbgx -debugArch x86 -c ".load c:\dev\tools\pykd\x86\pykd.dll"
WinDBG x86, build 10.0.15063.0
Python 2.7.13, but I tried many other versions as well.
You need python 2.7.13 x86
After installation you can check it visibility for pykd with command pykd.info - it should show path to python. For python 2.7 it is commonly C:\windows\system32\python27.dll
Also had the same issue, in the end it depends on which windbg version you are using, and what python versions you have installed;
If it is windbg x86, you need python 32 bits installed.
If it is windbg x64, you need python 64 bits installed.
I did not have to add any specific version to the PATH, I have 3 versions of python in my system; python2.7x86, python2.7x64 and python3x64 and if I run !pykd.info in windbgx86 it recognizes both x86 pythons and if I run it in sindbgx64 it recognizes the x64 python.
If your !pykd.info does not list any python, you probably have them mixed up (you only have pythonx86 while running windbgx64, or you only have pythonx64 while running windbgx86).
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
I'm trying to install log4cxx with MinGW on my Windows box but need to install apr and apr-util first.
I've been following the guide on Apache's website and installed the version of Python they listed but get an error about Python not being found:
$ buildconf
buildconf: checking installation...
buildconf: python not found.
You need python installed
to build APR from SVN.
I used the Python installer linked in the guide so I assume it's the correct version.
Do I have to tell MinGW or MSYS where Python is and, if so, how do I actually do that?
Also, everything is running 32-bit right now.
Any help would be appreciated!
Thanks
You need to add the location where you installed Python to your PATH environment variable. I would go to the following link that discusses setting PATH in Windows
you need to add the path in MinGw C:\MinGW\msys\1.0\etc in the fstab file as below
Win32_Path Mount_Point
c:/mingw /mingw
c:/ActiveState/perl /perl
C:/Python25
I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries)
I had the same issue, but on Windows 7, and a restart didn't fix it.
I already had gVim 7.3 installed. At the time of writing the current Python version was 3.3, so I installed that. But :has ("python") and :has ("python3") still returned 0.
After much trial and error, I determined that:
If gVim is 32-bit, and it usually is even on 64-bit Windows (you can confirm using the :version command), then you need the 32-bit python installation as well
No restart of Windows 7 is required
The version of python needs to match the version that gVim is compiled for as it looks for a specific DLL name. You can work this out from the :version command in gVim, which gives something like:
Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32
-DFEAT_CSCOPE -DFEAT_ NETBEANS_INTG -DFEAT_XPM_W32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjGOLYHTR/ / Ox /GL -DNDEBUG /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DDYNAMI C_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL
-DDYNAMIC_TCL_DLL=\"tcl83.dll\" -DDYNAM IC_TCL_VER=\"8.3\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -D FEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python31.dll\" -DFEAT_PERL -DDYNAMI C_PERL -DDYNAMIC_PERL_DLL=\"perl512.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 1 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby191.dll\" -DFEAT_BIG /Fd.\ObjGOLYHTR/ /Zi
So the above told me that I don't actually want python 3.3, I need 3.1 (or 2.7). After installing python 3.1, :has ("python") still returns 0, but :has ("python3") now returns 1. That should mean that python based scripts will now work!
I imagine future versions of gVim may be compiled against other versions of python, but using this method should let you work out which version is required.
Usually, python support is built in the official gvim distribution.
You will need to install python though: Python Downloads
to check if vim supports python:
:echo has("python")
I encountered this problem on Windows 7 64-bit. I realized I was using 64-bit Python 2.7.3 and 32-bit vim 7.3-46. I reinstalled both as 32-bit versions and then restarted the computer. Now it works.
If you have installed Python via one of the Windows installers it is probably compiled with Python 2.7 support. You can verify this by running:
:version
It will spit out all the options Vim was compiled with. Yours should say something like
+python/dyn +python3\dyn
This means you have support for python 2.7 and 3.x. If you already have 2.5 it won't work. You will need to upgrade to either 2.7 or 3.x.
Sorry for a late contribution.
The problem is that you can not mix x86 vim with x64 python libs, and all suggested solutions boil down to reinstalling x86 python.
Well, I do not want to reinstall Python, Ruby and who knows what else dependent on those just because vim does not officially provide fair x64 distribution on windows. The good news is that you can still find it well hidden at http://vim.wikia.com/wiki/Where_to_download_Vim . Good luck, and take care of Python library versions.
The accepted answer didn't solve my problem, so I decide to post the solution I found after some efforts.
First, as the accepted answer pointed out, you'll need both gVim compiled with python enabled, and a corresponding python installation. Make sure they are both 32-bit or 64-bit.
I found that the default build from www.vim.org didn't enable python, also it seemed to be 32-bit, which didn't match my python27. What I ended up with was the build "gvim_8.0.0003_x64.zip" from this vim Git repository
I then unzipped it, copied the "vim80" folder into the official vim installation location (created by the 32-bit installation downloaded www.vim.org).
Now vim works with my 64-bit python2.7 .
UPDATE 02/24/2017:
The procedure above failed on another machine where the local python installation is 2.7.9 . My Python version is 2.7.11 when I succeeded.
So, it seems the build from the vim Git repository works for a specific Python version. Try update your Python installation to 2.7.11 if you can. If you have to use an older version of Python, then maybe you need to build the Vim source code on your machine. It's not too hard following the instructions, and use the Visual Studio provided cmd instead of the Windows default cmd.
Add following scripts to your .vimrc
set pythonthreedll = python36.dll
Most distribution of vim in Windows is loading python dynamically, you must tell vim what the dll is, and make sure that python36.dll is in your PATH environment variable.
I had a similar problem. I've been enjoying vim's omni-completion feature for some years,using Windows XP, Python 2.7, gVim 7. Recently I moved to a new PC running Windows 8.1. I installed gVim and the plugins I like, then tried out everything. Omni-completion gave an error, saying I needed the version of vim compiled with Python support. At that stage, I had not yet installed Python. The solution was to install Python then re-install vim. Omni-conpletion now works. Perhaps the order of installation matters.
When I typed :version, it revealed that my Vim was not compiled with Python. Perhaps because I did not have Python (32-bit?) at the time.
I did install 32-bit Python as suggested, but reinstalling Vim seemed necessary.
After reading the above, I can confirm that on Win8.1 it does matter the order you install them (least for me it did). I had 32bit VIM 7.4 installed for a few months, then tried adding Python and couldn't do it. Left Python 2.7.9 installed and uninstalled/reinstalled VIM and now it works.
Download the one called "OLE GUI executable"
After trying all answers in this thread without success, the following worked for me (Win10, Python 2.7 32bit, gvim 7.4 32bit):
Reinvoke the Python Installer, select Change Python
Select the Option Add Python to Path, which is off by default
After the installer is done, restart your machine
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.