ctypes error

Discussion in 'Python' started by Gib Bogle, Jan 15, 2010.

  1. Gib Bogle

    Gib Bogle Guest

    I have a simple demo program (on Windows XP) that uses the ctypes module to load
    a DLL. This program works as expected with Python 2.5.4, but fails with Python
    2.6.4 (on a different machine, each machine has only one Python version
    installed), with these messages:

    File "demo.py", line 37, in <module>
    mydll = windll.LoadLibrary("DEMO.DLL")
    File "c:\python26\lib\ctypes\__init__.py, line 431, in LoadLibrary
    return self._dlltype(name)
    File "c:\python26\lib\ctypes\__init__.py, line 353, in __init__
    self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 14001] This application has failed to start because the
    application configuration is incorrect. Reinstalling the application may fix
    this problem

    It isn't clear to me what the "application" is. As far as I know I didn't
    install anything except Python 2.6.4. Is it possible that ctypes doesn't work
    with 2.6.4?
     
    Gib Bogle, Jan 15, 2010
    #1
    1. Advertising

  2. Gib Bogle

    Gib Bogle Guest

    It has occurred to me that the error may have nothing to do with ctypes. The
    DLL was built on one machine and copied to the other (which doesn't have the
    compiler installed). Although both machines are running Windows XP, there might
    be some subtle differences.

    I see that the build machine has XP Professional, Version 2002, Service Pack 2,
    while the machine that fails to load the DLL has XP Home Edition, Version 2002,
    Service Pack 3. Who knows.
     
    Gib Bogle, Jan 15, 2010
    #2
    1. Advertising

  3. Gib Bogle

    Dave Angel Guest

    >Gib Bogle wrote:
    >>I have a simple demo program (on Windows XP) that uses the ctypes

    module to load a DLL.
    >>This program works as expected with Python 2.5.4, but fails with

    Python 2.6.4 (on a different
    >> machine, each machine has only one Python version installed), with

    these messages:

    >>File "demo.py", line 37, in <module>
    >> mydll = windll.LoadLibrary("DEMO.DLL")
    >>File "c:\python26\lib\ctypes\__init__.py, line 431, in LoadLibrary
    >> return self._dlltype(name)
    >>File "c:\python26\lib\ctypes\__init__.py, line 353, in __init__
    >> self._handle = _dlopen(self._name, mode)
    >>WindowsError: [Error 14001] This application has failed to start

    because the application configuration is incorrect. Reinstalling the
    application may fix this problem
    >>
    >>It isn't clear to me what the "application" is. As far as I know I

    didn't install anything except Python 2.6.4. Is it possible that ctypes
    doesn't work with 2.6.4?


    Gib Bogle wrote:
    > <div class="moz-text-flowed" style="font-family: -moz-fixed">It has
    > occurred to me that the error may have nothing to do with ctypes. The
    > DLL was built on one machine and copied to the other (which doesn't
    > have the compiler installed). Although both machines are running
    > Windows XP, there might be some subtle differences.
    >
    > I see that the build machine has XP Professional, Version 2002,
    > Service Pack 2, while the machine that fails to load the DLL has XP
    > Home Edition, Version 2002, Service Pack 3. Who knows.
    >
    > </div>
    >

    The application is "python.exe". And usually, when it gives such an
    error, there's a missing DLL, or one of improper version.

    I think you want to run Dependency-Walker. See
    http://msdn.microsoft.com/en-us/library/ms235265.aspx

    for a description, and follow its link to
    http://go.microsoft.com/fwlink/?linkid=132640

    to download it.

    DaveA
     
    Dave Angel, Jan 15, 2010
    #3
  4. Gib Bogle

    Terry Reedy Guest

    On 1/15/2010 2:00 AM, Gib Bogle wrote:
    > It has occurred to me that the error may have nothing to do with ctypes.
    > The DLL was built on one machine and copied to the other (which
    > doesn't have the compiler installed). Although both machines are running
    > Windows XP, there might be some subtle differences.


    Python 2.5 and Python 2.6 are built with different versions of Microsoft
    Visual C. That could be your problem.
     
    Terry Reedy, Jan 15, 2010
    #4
  5. Gib Bogle

    Gib Bogle Guest

    Gib Bogle wrote:
    > It has occurred to me that the error may have nothing to do with
    > ctypes. The DLL was built on one machine and copied to the other (which
    > doesn't have the compiler installed). Although both machines are
    > running Windows XP, there might be some subtle differences.
    >
    > I see that the build machine has XP Professional, Version 2002, Service
    > Pack 2, while the machine that fails to load the DLL has XP Home
    > Edition, Version 2002, Service Pack 3. Who knows.


    I'm a bit embarrassed to report that the problem has nothing to do with Python.
    My DLL was built with dynamic library linking, and apparently there are some
    differences between the various Intel DLLs used on the two machines. Following
    advice from the Intel Fortran forum, I created the DLL with static library
    linking, and now all works as expected. Sorry to waste your time.
     
    Gib Bogle, Jan 16, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henk Punt
    Replies:
    0
    Views:
    419
    Henk Punt
    Jul 23, 2004
  2. Max M
    Replies:
    4
    Views:
    773
    Max M
    Oct 7, 2004
  3. Michele Petrazzo

    Ctypes error

    Michele Petrazzo, Oct 7, 2004, in forum: Python
    Replies:
    3
    Views:
    614
    Thomas Heller
    Oct 8, 2004
  4. Martin P. Hellwig
    Replies:
    3
    Views:
    497
    Martin P. Hellwig
    Jul 15, 2006
  5. Replies:
    0
    Views:
    524
Loading...

Share This Page