Thread: Python 3.2 XP64 and Numpy...

Python 3.2 XP64 and Numpy...

From
Rémi Cura
Date:
Hey dear List,

On a windows XP 64.

I installed python (64b),
it works.
CReating plpython3u works, and python works within database.

I installed numpy (manually compiled,64b),
it works outside of Postgres,
but inside a plpython3u function, simply doing
'import numpy' raises an error saying that python 32 is not a valid win32 application.

I'm really stuck and have checked everything I could (path, rights, depends...)

Somebody has an idea of how to make it works?

Thanks
Cheers,
Rémi-C

Re: Python 3.2 XP64 and Numpy...

From
Adrian Klaver
Date:
On 05/27/2015 09:49 AM, Rémi Cura wrote:
> Hey dear List,
>
> On a windows XP 64.
>
> I installed python (64b),
> it works.

What version of Python 2 or 3 or both?

What does python -V show at the command line?

> CReating plpython3u works, and python works within database.
>
> I installed numpy (manually compiled,64b),
> it works outside of Postgres,
> but inside a plpython3u function, simply doing
> 'import numpy' raises an error saying that python 32 is not a valid
> win32 application.

Is there a 32 bit version of numpy on your machine?

>
> I'm really stuck and have checked everything I could (path, rights,
> depends...)

Does that include PYTHONPATH?

>
> Somebody has an idea of how to make it works?
>
> Thanks
> Cheers,
> Rémi-C


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Python 3.2 XP64 and Numpy...

From
Rémi Cura
Date:
​Hey thanks for the help !  

> > Hey dear List,

> >

> > On a windows XP 64.

> >

> > I installed python (64b),

> > it works.

>

> What version of Python 2 or 3 or both?

>

> What does python -V show at the command line?

>

 

Python 3.2 and python 2.6, both 64bits are installed on the PC.

When I return "sys.version" from inside a plpython3u function, i get

3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)]

 

> > CReating plpython3u works, and python works within database.

> >

> > I installed numpy (manually compiled,64b),

> > it works outside of Postgres,

> > but inside a plpython3u function, simply doing

> > 'import numpy' raises an error saying that python 32 is not a valid

> > win32 application.

>

> Is there a 32 bit version of numpy on your machine?

 

Nope! I freshly installed all of this.

Numpy is installed only in my Python 3.2.

My python 2.6 does not have numpy.

 

I tried:

C:\Python32>python.exe

Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy

>>> print(numpy.__version__)

1.9.2

>>> 

 

but when i try to import numpy from a plpython3u function it raised error...

 

 

>

> >

> > I'm really stuck and have checked everything I could (path, rights,

> > depends...)

>

> Does that include PYTHONPATH?

 

Yes! i tried to print python path from a plpython3u function (return  sys.path), i get :

"['C:\\WINDOWS\\system32\\python32.zip', 'C:\\Python32\\Lib', 'C:\\Python32\\DLLs', 'F:\\postgresData', 'C:\\Program Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages']"

 

I look in all those folders and the only numpy i found is the one i have recompiled in "C:\\Python32\\lib\\site-packages" 

Re: Python 3.2 XP64 and Numpy...

From
Alban Hertroys
Date:
> On 28 May 2015, at 17:54, Rémi Cura <remi.cura@gmail.com> wrote:
>
> I tried:
>
> C:\Python32>python.exe
>
> Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32

Ehm, this seems significant? -----------------------------------------------------------------------^^^^^

It looks like you're trying to use 64-bit binaries on a 32-bit OS.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



Re: Python 3.2 XP64 and Numpy...

From
Adrian Klaver
Date:
On 05/28/2015 08:54 AM, Rémi Cura wrote:
> ​Hey thanks for the help !
>
>> > Hey dear List,
>
>> >
>
>> > On a windows XP 64.
>
>> >
>
>> > I installed python (64b),
>
>> > it works.
>
>>
>
>> What version of Python 2 or 3 or both?
>
>>
>
>> What does python -V show at the command line?
>
>>
>
> Python 3.2 and python 2.6, both 64bits are installed on the PC.
>
> When I return "sys.version" from inside a plpython3u function, i get
>
> 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)]
>
>> > CReating plpython3u works, and python works within  database.
>
>> >
>
>> > I installed numpy (manually compiled,64b),
>
>> > it works outside of Postgres,
>
>> > but inside a plpython3u function, simply doing
>
>> > 'import numpy' raises an error saying that python 32  is not a valid
>
>> > win32 application.
>
>>
>
>> Is there a 32 bit version of numpy on your machine?
>
> Nope! I freshly installed all of this.
>
> Numpy is installed only in my Python 3.2.
>
> My python 2.6 does not have numpy.
>
> I tried:
>
> C:\Python32>python.exe
>
> Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit
> (AMD64)] on win32
>
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> import numpy
>
>>>> print(numpy.__version__)
>
> 1.9.2
>
>>>>
>
> but when i try to import numpy from a plpython3u function it raised
> error...

Can we see the actual entire error?

>
>>
>
>> >
>
>> > I'm really stuck and have checked everything I could  (path, rights,
>
>> > depends...)
>
>>
>
>> Does that include PYTHONPATH?
>
> Yes! i tried to print python path from a plpython3u function (return
> sys.path), i get :
>
> "['C:\\WINDOWS\\system32\\python32.zip', 'C:\\Python32\\Lib',
> 'C:\\Python32\\DLLs', 'F:\\postgresData', 'C:\\Program
> Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
> 'C:\\Python32\\lib\\site-packages']"

So how many Pythons do you have installed?

I know you mentioned the two above, but could you have another that got
installed without you knowing?

In other words have you installed something like Anaconda or Python(x,y)
in the past?

>
> I look in all those folders and the only numpy i found is the one i have
> recompiled in "C:\\Python32\\lib\\site-packages"
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Python 3.2 XP64 and Numpy...

From
Rémi Cura
Date:
Hey, thanks to help me with that.
I started fresh to have a truly reproducible process,
so you can have all information and rule out some error possibilities.

 - Uninstall all python.
 - Check that PythonPath doesn't exist anymore
 - check that python doesn't exist anymore

 - install python 3.2.5 64 bit from official python website into C/Python32

 - Reload configuration for server.

 - create plpython3u , create a python function, test it (show path)

   * It works, python path is
    'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib', 'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages'

 - Donwload latest numpy from website.
 - ON antoher PC
   * Compile numpy with visual 2008 , 64 bit
   * Create an binary installer for windows (using python.exe setup.py )with proper argument

 - On the server :
 - install numpy with the compiled installer.


 - check that numpy is correctly installer in C:\Python32\Lib\site-packages
 - using an external terminal, check that numpy works (import numpy -> OK)

 - Now, define a plpython3u function containing "import numpy"

 - Run the function --> error is
  "ERREUR:  ImportError: DLL load failed: Le module spécifié est introuvable.",
   which roughly translate to
  "ERROR: ImportError : DLL load failed : the specified module couldn't be found".

 - Create a plpython3u function returning sys.path
the path is "C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib', 'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages"
numpy is in this path, in C:\\Python32\\lib\\site-packages
All user of the computer have all rights on the C:\\Python32\\lib\\site-packages folder


 - execute `import imp; imp.find_package('numpy')` within the plpython3u function
   -> returns "None, 'C:\\Python32\\lib\\site-packages\\numpy', ('', '', 5)"

 - create a helloworld module , put it next to numpy, try to call it
   -> it gets called

I really don't see what I can do more.

Cheers,
Rémi-C

Re: Python 3.2 XP64 and Numpy...

From
Rémi Cura
Date:
Here is the test code
---------------
--creating plpython3u
DROP LANGUAGE plpython3u CASCADE;
CREATE LANGUAGE plpython3u ;


--create a test function
DROP FUNCTION IF EXISTS rc_test_python(   );
CREATE FUNCTION rc_test_python(  )
RETURNS void
AS $$"""
@brief This function test python
"""
import sys
import imp
#sys.path.insert(0, 'C:\\Python32\\Lib\\site-packages\\numpy')
plpy.notice(sys.path)
plpy.notice('importing numpy')
#import numpy #first way to do it

file, pathname, description = imp.find_module('numpy')
plpy.notice(file, pathname, description) # numpy was found
imp.load_module('numpy',file, pathname, description ) #second way to do it
plpy.notice('end of importing numpy, this message won t show, an exception is raised before')
#plpy.notice(numpy.__version__)
import helloworld as h
imp.reload(h)
s = h.helloworld()
plpy.notice(s)
return
$$ LANGUAGE plpython3u IMMUTABLE STRICT;

--call function
SELECT *
FROM rc_test_python(   ) ;
---------------------
---------------

2015-06-01 18:09 GMT+02:00 Rémi Cura <remi.cura@gmail.com>:
Hey, thanks to help me with that.
I started fresh to have a truly reproducible process,
so you can have all information and rule out some error possibilities.

 - Uninstall all python.
 - Check that PythonPath doesn't exist anymore
 - check that python doesn't exist anymore

 - install python 3.2.5 64 bit from official python website into C/Python32

 - Reload configuration for server.

 - create plpython3u , create a python function, test it (show path)

   * It works, python path is
    'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib', 'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages'

 - Donwload latest numpy from website.
 - ON antoher PC
   * Compile numpy with visual 2008 , 64 bit
   * Create an binary installer for windows (using python.exe setup.py )with proper argument

 - On the server :
 - install numpy with the compiled installer.


 - check that numpy is correctly installer in C:\Python32\Lib\site-packages
 - using an external terminal, check that numpy works (import numpy -> OK)

 - Now, define a plpython3u function containing "import numpy"

 - Run the function --> error is
  "ERREUR:  ImportError: DLL load failed: Le module spécifié est introuvable.",
   which roughly translate to
  "ERROR: ImportError : DLL load failed : the specified module couldn't be found".

 - Create a plpython3u function returning sys.path
the path is "C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib', 'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages"
numpy is in this path, in C:\\Python32\\lib\\site-packages
All user of the computer have all rights on the C:\\Python32\\lib\\site-packages folder


 - execute `import imp; imp.find_package('numpy')` within the plpython3u function
   -> returns "None, 'C:\\Python32\\lib\\site-packages\\numpy', ('', '', 5)"

 - create a helloworld module , put it next to numpy, try to call it
   -> it gets called

I really don't see what I can do more.

Cheers,
Rémi-C


Re: Python 3.2 XP64 and Numpy...

From
Adrian Klaver
Date:
On 06/01/2015 09:09 AM, Rémi Cura wrote:
> Hey, thanks to help me with that.
> I started fresh to have a truly reproducible process,
> so you can have all information and rule out some error possibilities.
>
>   - Uninstall all python.
>   - Check that PythonPath doesn't exist anymore
>   - check that python doesn't exist anymore
>
>   - install python 3.2.5 64 bit from official python website into C/Python32
>
>   - Reload configuration for server.
>
>   - create plpython3u , create a python function, test it (show path)
>
>     * It works, python path is
>      'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib',
> 'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program
> Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
> 'C:\\Python32\\lib\\site-packages'
>
>   - Donwload latest numpy from website.
>   - ON antoher PC

So what is the Python setup on this machine?

>     * Compile numpy with visual 2008 , 64 bit
>     * Create an binary installer for windows (using python.exe setup.py
> )with proper argument

The argument would be?

>
>   - On the server :
>   - install numpy with the compiled installer.

Best guess is that the numpy compilation you are doing on Machine A is
not compatible with what you have installed on Machine B(the server).

Have you looked at this:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

or

http://www.scipy.org/install.html
>
>
>   - check that numpy is correctly installer in C:\Python32\Lib\site-packages
>   - using an external terminal, check that numpy works (import numpy -> OK)
>
>   - Now, define a plpython3u function containing "import numpy"
>
>   - Run the function --> error is
>    "ERREUR:  ImportError: DLL load failed: Le module spécifié est
> introuvable.",
>     which roughly translate to
>    "ERROR: ImportError : DLL load failed : the specified module couldn't
> be found".
>
>   - Create a plpython3u function returning sys.path
> the path is "C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib',
> 'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program
> Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
> 'C:\\Python32\\lib\\site-packages"
> numpy is in this path, in C:\\Python32\\lib\\site-packages
> All user of the computer have all rights on the
> C:\\Python32\\lib\\site-packages folder
>
>
>   - execute `import imp; imp.find_package('numpy')` within the
> plpython3u function
>     -> returns "None, 'C:\\Python32\\lib\\site-packages\\numpy', ('',
> '', 5)"
>
>   - create a helloworld module , put it next to numpy, try to call it
>     -> it gets called
>
> I really don't see what I can do more.
>
> Cheers,
> Rémi-C
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Python 3.2 XP64 and Numpy...

From
Rémi Cura
Date:
Hey,
python is installed from official binary, 64 b for windows,
in C/Python32

I can't remember the argument, but it might be irrelevant.
The problem doesn't seem to be to install numpy, it works perfectly in the regular terminal.

The problem seems to be that postgres can't use correctly numpy.


I found no version of scipy installer for win 64 with python 3.2,
I tried several but not having the exact python version always end in failure.
The binaries you linked to are dependent on intel math kernel library, which I don't have.


Cheers,
Rémi-C


2015-06-01 19:41 GMT+02:00 Adrian Klaver <adrian.klaver@aklaver.com>:
On 06/01/2015 09:09 AM, Rémi Cura wrote:
Hey, thanks to help me with that.
I started fresh to have a truly reproducible process,
so you can have all information and rule out some error possibilities.

  - Uninstall all python.
  - Check that PythonPath doesn't exist anymore
  - check that python doesn't exist anymore

  - install python 3.2.5 64 bit from official python website into C/Python32

  - Reload configuration for server.

  - create plpython3u , create a python function, test it (show path)

    * It works, python path is
     'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib',
'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program
Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
'C:\\Python32\\lib\\site-packages'

  - Donwload latest numpy from website.
  - ON antoher PC

So what is the Python setup on this machine?

    * Compile numpy with visual 2008 , 64 bit
    * Create an binary installer for windows (using python.exe setup.py
)with proper argument

The argument would be?


  - On the server :
  - install numpy with the compiled installer.

Best guess is that the numpy compilation you are doing on Machine A is not compatible with what you have installed on Machine B(the server).

Have you looked at this:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

or

http://www.scipy.org/install.html



  - check that numpy is correctly installer in C:\Python32\Lib\site-packages
  - using an external terminal, check that numpy works (import numpy -> OK)

  - Now, define a plpython3u function containing "import numpy"

  - Run the function --> error is
   "ERREUR:  ImportError: DLL load failed: Le module spécifié est
introuvable.",
    which roughly translate to
   "ERROR: ImportError : DLL load failed : the specified module couldn't
be found".

  - Create a plpython3u function returning sys.path
the path is "C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib',
'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program
Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
'C:\\Python32\\lib\\site-packages"
numpy is in this path, in C:\\Python32\\lib\\site-packages
All user of the computer have all rights on the
C:\\Python32\\lib\\site-packages folder


  - execute `import imp; imp.find_package('numpy')` within the
plpython3u function
    -> returns "None, 'C:\\Python32\\lib\\site-packages\\numpy', ('',
'', 5)"

  - create a helloworld module , put it next to numpy, try to call it
    -> it gets called

I really don't see what I can do more.

Cheers,
Rémi-C



--
Adrian Klaver
adrian.klaver@aklaver.com

Re: Python 3.2 XP64 and Numpy...

From
Adrian Klaver
Date:
On 06/02/2015 01:24 AM, Rémi Cura wrote:
> Hey,
> python is installed from official binary, 64 b for windows,
> in C/Python32
>
> I can't remember the argument, but it might be irrelevant.
> The problem doesn't seem to be to install numpy, it works perfectly in
> the regular terminal.
>
> The problem seems to be that postgres can't use correctly numpy.

So  to be clear, you can import other modules into plpythonu3 and they work?

In your previous post you said:

"All user of the computer have all rights on the
C:\\Python32\\lib\\site-packages folder"

Do those rights extend down the sub-directories, in particular the numpy
package?

>
>
> I found no version of scipy installer for win 64 with python 3.2,
> I tried several but not having the exact python version always end in
> failure.
> The binaries you linked to are dependent on intel math kernel library,
> which I don't have.


Well it was worth a shot.

>
>
> Cheers,
> Rémi-C
>
>
> 2015-06-01 19:41 GMT+02:00 Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>>:
>
>     On 06/01/2015 09:09 AM, Rémi Cura wrote:
>
>         Hey, thanks to help me with that.
>         I started fresh to have a truly reproducible process,
>         so you can have all information and rule out some error
>         possibilities.
>
>            - Uninstall all python.
>            - Check that PythonPath doesn't exist anymore
>            - check that python doesn't exist anymore
>
>            - install python 3.2.5 64 bit from official python website
>         into C/Python32
>
>            - Reload configuration for server.
>
>            - create plpython3u , create a python function, test it (show
>         path)
>
>              * It works, python path is
>               'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\Lib',
>         'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program
>         Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
>         'C:\\Python32\\lib\\site-packages'
>
>            - Donwload latest numpy from website.
>            - ON antoher PC
>
>
>     So what is the Python setup on this machine?
>
>              * Compile numpy with visual 2008 , 64 bit
>              * Create an binary installer for windows (using python.exe
>         setup.py
>         )with proper argument
>
>
>     The argument would be?
>
>
>            - On the server :
>            - install numpy with the compiled installer.
>
>
>     Best guess is that the numpy compilation you are doing on Machine A
>     is not compatible with what you have installed on Machine B(the server).
>
>     Have you looked at this:
>     http://www.lfd.uci.edu/~gohlke/pythonlibs/
>
>     or
>
>     http://www.scipy.org/install.html
>
>
>
>            - check that numpy is correctly installer in
>         C:\Python32\Lib\site-packages
>            - using an external terminal, check that numpy works (import
>         numpy -> OK)
>
>            - Now, define a plpython3u function containing "import numpy"
>
>            - Run the function --> error is
>             "ERREUR:  ImportError: DLL load failed: Le module spécifié est
>         introuvable.",
>              which roughly translate to
>             "ERROR: ImportError : DLL load failed : the specified module
>         couldn't
>         be found".
>
>            - Create a plpython3u function returning sys.path
>         the path is "C:\\Windows\\system32\\python32.zip',
>         'C:\\Python32\\Lib',
>         'C:\\Python32\\DLLs', 'E:\\9.3\\data', 'C:\\Program
>         Files\\PostgreSQL\\9.3\\bin', 'C:\\Python32',
>         'C:\\Python32\\lib\\site-packages"
>         numpy is in this path, in C:\\Python32\\lib\\site-packages
>         All user of the computer have all rights on the
>         C:\\Python32\\lib\\site-packages folder
>
>
>            - execute `import imp; imp.find_package('numpy')` within the
>         plpython3u function
>              -> returns "None,
>         'C:\\Python32\\lib\\site-packages\\numpy', ('',
>         '', 5)"
>
>            - create a helloworld module , put it next to numpy, try to
>         call it
>              -> it gets called
>
>         I really don't see what I can do more.
>
>         Cheers,
>         Rémi-C
>
>
>
>     --
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com