Hi all,

Thanks for your replies. It wasn't a permissions issue. Apparently, not the 
full 
path name should be used. When I use os.chdir (by the way: why on earth isn't 
this called os.setcwd()?? That's consistent with os.getcwd()) and then use the 
file name only, it works. See the Idle session below. Thought it'd be nice to 
share this with you.

Best wishes,
Albert-Jan

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on 
win32
    
IDLE 1.2.4      
>>> import ctypes
>>> lib = ctypes.cdll.LoadLibrary("d:/temp/spss_io/win32/spssio32.dll")

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    lib = ctypes.cdll.LoadLibrary("d:/temp/spss_io/win32/spssio32.dll")
  File "C:\Python25\lib\ctypes\__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "C:\Python25\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] Kan opgegeven module niet vinden
>>> import os
>>> os.path.exists("d:/temp/spss_io/win32/spssio32.dll")
True
>>> os.chdir("d:/temp/spss_io/win32")
>>> lib = ctypes.cdll.LoadLibrary("spssio32.dll")
>>> dir(lib)
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__', '__getattr__', 
'__getattribute__', '__getitem__', '__hash__', '__init__', '__module__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 
'__weakref__', '_handle', '_name']
>>> 

 Cheers!!
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the 
Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




________________________________
From: Alan Gauld <[email protected]>
To: [email protected]
Sent: Mon, March 7, 2011 7:26:15 PM
Subject: Re: [Tutor] ctypes question


"Pacific Morrowind" <[email protected]> wrote

> but that path doesn't actually exist... replace that path with either
> r"d:/temp/spssio32.dll" or with "d://temp//spssio32.dll"; otherwise the
> /t will be transformed into a tab.

You've got your / and \ mixed up.

Forward slashes (/) are fine in Windows paths. It's back
slashes(\) that need escaping or raw stringing. \t is tab...

On the original ask - could it be a permissions issue?
Does your app have acess to the file?

Alan G. 

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



      
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to