[osgeo4w-dev] Re: [osgeo4w] #267: ctypes version conflict with numpy

OSGeo4W trac_osgeo4w at osgeo.org
Fri Feb 17 12:47:05 EST 2012


#267: ctypes version conflict with numpy
-------------------------+--------------------------------------------------
Reporter:  davidfawcett  |       Owner:  osgeo4w-dev@…              
    Type:  defect        |      Status:  new                        
Priority:  major         |   Component:  Package                    
 Version:                |    Keywords:  python ctypes numpy        
-------------------------+--------------------------------------------------

Old description:

> When I try to import numpy, I get the below error.  It appears that it
> looks for ctypeslib.py in the right spot, but then it goes to the path
> for my 'system python', which is Python 2.5 for ctypes\__init__.py.
>
> I just ran the OSGeo4W installer to update all of the packages.
>
> GDAL 1.8.1, released 2011/07/09
>
> H:\>python
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
> on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\numpy\__init__.py",
> line 154,
>  in <module>
>     import ctypeslib
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\numpy\ctypeslib.py",
> line 60,
>  in <module>
>     import ctypes
>   File "D:\Python25\lib\ctypes\__init__.py", line 20, in <module>
>     raise Exception, ("Version number mismatch", __version__,
> _ctypes_version)
> Exception: ('Version number mismatch', '1.0.2', '1.1.0')
> >>>

New description:

 When I try to import numpy, I get the below error.  It appears that it
 looks for ctypeslib.py in the right spot, but then it goes to the path for
 my 'system python', which is Python 2.5 for ctypes\__init__.py.

 I just ran the OSGeo4W installer to update all of the packages.

 GDAL 1.8.1, released 2011/07/09
 {{{
 H:\>python
 Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
 on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\OSGeo4W\apps\Python27\lib\site-packages\numpy\__init__.py",
 line 154,
  in <module>
     import ctypeslib
   File "C:\OSGeo4W\apps\Python27\lib\site-packages\numpy\ctypeslib.py",
 line 60,
  in <module>
     import ctypes
   File "D:\Python25\lib\ctypes\__init__.py", line 20, in <module>
     raise Exception, ("Version number mismatch", __version__,
 _ctypes_version)
 Exception: ('Version number mismatch', '1.0.2', '1.1.0')
 >>>
 }}}

--

Comment(by maphew):

 David, the system python variables needs to be removed from the
 environment before starting the o4w python. To see the existing python
 env, open a command prompt and type:
 {{{
 set |findstr /i "python"
 }}}
 If you see something like the below you'll have a conflict with the
 Osgeo4W python:
 {{{
 Path=C:\Python26;C:\Python26\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\sysWOW64
 PYTHONHOME=C:\Python26
 PYTHONPATH=C:\Python26;C:\Python26\Lib;C:\Python26\DLLs
 }}}

 To fix this you'll need to remove the existing python settings from the
 system default (''[Winkey]-[pause/break] > Advanced > Environment'') or
 take care to always start python from inside a new shell which resets
 those variables, e.g. from a batch file:
 {{{
 @echo off
 set PYTHONHOME=
 set PYTHONPATH=
 set
 PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\sysWOW64;
 call c:\osgeo4w\osgeo4w.bat
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/osgeo4w/ticket/267#comment:1>
OSGeo4W <http://trac.osgeo.org/osgeo4w>
OSGeo4W is the Windows installer and package environment for the OSGeo stack.


More information about the osgeo4w-dev mailing list