<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>PostgreSQL on windows : plpythonu and &quot;specified module could not be found&quot; error (Logilab.org) RSS Feed</title>
    <description></description>
    <link>http://www.logilab.org/blogentry/22199</link>
<item>
<guid isPermaLink="true">http://www.logilab.org/blogentry/22199</guid>
  <title>PostgreSQL on windows : plpythonu and &quot;specified module could not be found&quot; error</title>
  <link>http://www.logilab.org/blogentry/22199</link>
  <description>&lt;p&gt;I recently had to (remotely) debug an issue on windows involving
&lt;a class=&quot;reference&quot; href=&quot;http://www.postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt; and &lt;a class=&quot;reference&quot; href=&quot;http://www.postgresql.org/docs/8.4/interactive/plpython.html&quot;&gt;PL/Python&lt;/a&gt;. Basically, two very similar computers, with
Python2.5 installed via &lt;a class=&quot;reference&quot; href=&quot;http://www.pythonxy.com/&quot;&gt;python(x,y)&lt;/a&gt;, PostgreSQL 8.3.8 installed via
the &lt;a class=&quot;reference&quot; href=&quot;http://www.postgresql.org/ftp/binary/v8.3.8/win32/&quot;&gt;binary installer&lt;/a&gt;. On the first machine &lt;tt class=&quot;docutils literal&quot;&gt;create language
plpythonu;&lt;/tt&gt; worked like a charm, and on the other one, it failed with
&lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;C:\\Program&lt;/span&gt; &lt;span class=&quot;pre&quot;&gt;Files\\Postgresql\\8.3\\plpython.dll:&lt;/span&gt; specified module
could not be found&lt;/tt&gt;. This is caused by the dynamic linker not finding
some DLL. Using &lt;a class=&quot;reference&quot; href=&quot;http://www.dependencywalker.com/&quot;&gt;Depends.exe&lt;/a&gt; showed that
&lt;tt class=&quot;docutils literal&quot;&gt;plpython.dll&lt;/tt&gt; looks for &lt;tt class=&quot;docutils literal&quot;&gt;python25.dll&lt;/tt&gt; (the one it was built
against in the 8.3.8 installer), but that the DLL was there.&lt;/p&gt;
&lt;p&gt;I&#39;ll save the various things we tried and jump directly to the
solution. After much head scratching, it turned out that the first
computer had &lt;a class=&quot;reference&quot; href=&quot;http://tortoisehg.bitbucket.org/&quot;&gt;TortoiseHg&lt;/a&gt; installed. This caused &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;C:\\Program&lt;/span&gt;
&lt;span class=&quot;pre&quot;&gt;Files\\TortoiseHg&lt;/span&gt;&lt;/tt&gt; to be included in the System PATH environment
variable, and that directory contains &lt;tt class=&quot;docutils literal&quot;&gt;python25.dll&lt;/tt&gt;. On the other
hand &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;C:\\Python25&lt;/span&gt;&lt;/tt&gt; was in the user&#39;s PATH environment variable on both
computers. As the database Windows service runs using a dedicated
local account (typically with login &lt;tt class=&quot;docutils literal&quot;&gt;postgres&lt;/tt&gt;), it would not have
&lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;C:\\Python25&lt;/span&gt;&lt;/tt&gt; in its PATH, but if TortoiseHg was there, it would
find the DLL in some other directory. So the solution was to add
&lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;C:\\Python25&lt;/span&gt;&lt;/tt&gt; to the system PATH.&lt;/p&gt;
</description>
  <dc:date>2010-03-22T14:29-01:00</dc:date>
</item>
  </channel>
</rss>