Opened 12 years ago

Last modified 3 years ago

#267 closed defect

ctypes version conflict with numpy — at Version 1

Reported by: davidfawcett Owned by: osgeo4w-dev@…
Priority: major Component: Package
Version: Keywords: python ctypes numpy
Cc:

Description (last modified by maphew)

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')
>>>

Change History (1)

comment:1 by maphew, 12 years ago

Description: modified (diff)

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
Note: See TracTickets for help on using tickets.