import dll instead of pyd

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jrh

    import dll instead of pyd

    Hello,

    From previous posts and documentation it seems python should be able
    to import a module that is compiled into a .dll just as well as
    a .pyd. I have a pyd that works fine, but after renaming it to dll the
    import fails. Running python with -vv flag indicates it doesn't
    actually look for the dll (see below). Has dll import been defeatured
    in python?

    Thanks!
    >>import _mydllpythonmod ule
    # trying _mydllpythonmod ule.pyd
    # trying _mydllpythonmod ule.py
    # trying _mydllpythonmod ule.pyw
    # trying _mydllpythonmod ule.pyc
    # trying C:\Python25\DLL s\_mydllpythonm odule.pyd
    # trying C:\Python25\DLL s\_mydllpythonm odule.py
    # trying C:\Python25\DLL s\_mydllpythonm odule.pyw
    # trying C:\Python25\DLL s\_mydllpythonm odule.pyc
    # trying C:\Python25\lib \_mydllpythonmo dule.pyd
    # trying C:\Python25\lib \_mydllpythonmo dule.py
    # trying C:\Python25\lib \_mydllpythonmo dule.pyw
    # trying C:\Python25\lib \_mydllpythonmo dule.pyc
    # trying C:\Python25\lib \lib-tk\_mydllpython module.pyd
    # trying C:\Python25\lib \lib-tk\_mydllpython module.py
    # trying C:\Python25\lib \lib-tk\_mydllpython module.pyw
    # trying C:\Python25\lib \lib-tk\_mydllpython module.pyc
    # trying C:\Python25\_my dllpythonmodule .pyd
    # trying C:\Python25\_my dllpythonmodule .py
    # trying C:\Python25\_my dllpythonmodule .pyw
    # trying C:\Python25\_my dllpythonmodule .pyc
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py d
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py w
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py c
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyd
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.py
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyw
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyc
    # trying C:\Python25\lib \site-packages\win32\ lib
    \_mydllpythonmo dule.pyd
    # trying C:\Python25\lib \site-packages\win32\ lib\_mydllpytho nmodule.py
    # trying C:\Python25\lib \site-packages\win32\ lib
    \_mydllpythonmo dule.pyw
    # trying C:\Python25\lib \site-packages\win32\ lib
    \_mydllpythonmo dule.pyc
    # trying C:\Python25\lib \site-packages\Python win
    \_mydllpythonmo dule.pyd
    # trying C:\Python25\lib \site-packages\Python win\_mydllpytho nmodule.py
    # trying C:\Python25\lib \site-packages\Python win
    \_mydllpythonmo dule.pyw
    # trying C:\Python25\lib \site-packages\Python win
    \_mydllpythonmo dule.pyc
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named _mydllpythonmod ule
    >>>
  • Nick Dumas

    #2
    Re: import dll instead of pyd

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Is this DLL in the same directory as your script? If not, is it part of
    your pythonpath? If neither are true, then you won't be able to import
    it, regardless of whether it's a good file or not.

    jrh wrote:
    Hello,
    >
    From previous posts and documentation it seems python should be able
    to import a module that is compiled into a .dll just as well as
    a .pyd. I have a pyd that works fine, but after renaming it to dll the
    import fails. Running python with -vv flag indicates it doesn't
    actually look for the dll (see below). Has dll import been defeatured
    in python?
    >
    Thanks!
    >
    >>>import _mydllpythonmod ule
    # trying _mydllpythonmod ule.pyd
    # trying _mydllpythonmod ule.py
    # trying _mydllpythonmod ule.pyw
    # trying _mydllpythonmod ule.pyc
    # trying C:\Python25\DLL s\_mydllpythonm odule.pyd
    # trying C:\Python25\DLL s\_mydllpythonm odule.py
    # trying C:\Python25\DLL s\_mydllpythonm odule.pyw
    # trying C:\Python25\DLL s\_mydllpythonm odule.pyc
    # trying C:\Python25\lib \_mydllpythonmo dule.pyd
    # trying C:\Python25\lib \_mydllpythonmo dule.py
    # trying C:\Python25\lib \_mydllpythonmo dule.pyw
    # trying C:\Python25\lib \_mydllpythonmo dule.pyc
    # trying C:\Python25\lib \lib-tk\_mydllpython module.pyd
    # trying C:\Python25\lib \lib-tk\_mydllpython module.py
    # trying C:\Python25\lib \lib-tk\_mydllpython module.pyw
    # trying C:\Python25\lib \lib-tk\_mydllpython module.pyc
    # trying C:\Python25\_my dllpythonmodule .pyd
    # trying C:\Python25\_my dllpythonmodule .py
    # trying C:\Python25\_my dllpythonmodule .pyw
    # trying C:\Python25\_my dllpythonmodule .pyc
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py d
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py w
    # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py c
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyd
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.py
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyw
    # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyc
    # trying C:\Python25\lib \site-packages\win32\ lib
    \_mydllpythonmo dule.pyd
    # trying C:\Python25\lib \site-packages\win32\ lib\_mydllpytho nmodule.py
    # trying C:\Python25\lib \site-packages\win32\ lib
    \_mydllpythonmo dule.pyw
    # trying C:\Python25\lib \site-packages\win32\ lib
    \_mydllpythonmo dule.pyc
    # trying C:\Python25\lib \site-packages\Python win
    \_mydllpythonmo dule.pyd
    # trying C:\Python25\lib \site-packages\Python win\_mydllpytho nmodule.py
    # trying C:\Python25\lib \site-packages\Python win
    \_mydllpythonmo dule.pyw
    # trying C:\Python25\lib \site-packages\Python win
    \_mydllpythonmo dule.pyc
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named _mydllpythonmod ule
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.9 (MingW32)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iEYEARECAAYFAki JNGwACgkQLMI5fn dAv9hykgCcDf4cT ZU0iDo+ELQ5aFGs 9FIO
    8GEAn3+egrPDtNr lbsssqti8YeZXXI eM
    =q31k
    -----END PGP SIGNATURE-----

    Comment

    • jrh

      #3
      Re: import dll instead of pyd

      Yes it is in the same directory. The problem is it does not seem to
      look for dll's at all. So is this by design, or am I missing
      something?

      On 25 Juli, 10:03, Nick Dumas <drako...@gmail .comwrote:
      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1
      >
      Is this DLL in the same directory as your script? If not, is it part of
      your pythonpath? If neither are true, then you won't be able to import
      it, regardless of whether it's a good file or not.
      >
      >
      >
      jrh wrote:
      Hello,
      >
      From previous posts and documentation it seems python should be able
      to import a module that is compiled into a .dll just as well as
      a .pyd. I have a pyd that works fine, but after renaming it to dll the
      import fails. Running python with -vv flag indicates it doesn't
      actually look for the dll (see below). Has dll import been defeatured
      in python?
      >
      Thanks!
      >
      >>import _mydllpythonmod ule
      # trying _mydllpythonmod ule.pyd
      # trying _mydllpythonmod ule.py
      # trying _mydllpythonmod ule.pyw
      # trying _mydllpythonmod ule.pyc
      # trying C:\Python25\DLL s\_mydllpythonm odule.pyd
      # trying C:\Python25\DLL s\_mydllpythonm odule.py
      # trying C:\Python25\DLL s\_mydllpythonm odule.pyw
      # trying C:\Python25\DLL s\_mydllpythonm odule.pyc
      # trying C:\Python25\lib \_mydllpythonmo dule.pyd
      # trying C:\Python25\lib \_mydllpythonmo dule.py
      # trying C:\Python25\lib \_mydllpythonmo dule.pyw
      # trying C:\Python25\lib \_mydllpythonmo dule.pyc
      # trying C:\Python25\lib \lib-tk\_mydllpython module.pyd
      # trying C:\Python25\lib \lib-tk\_mydllpython module.py
      # trying C:\Python25\lib \lib-tk\_mydllpython module.pyw
      # trying C:\Python25\lib \lib-tk\_mydllpython module.pyc
      # trying C:\Python25\_my dllpythonmodule .pyd
      # trying C:\Python25\_my dllpythonmodule .py
      # trying C:\Python25\_my dllpythonmodule .pyw
      # trying C:\Python25\_my dllpythonmodule .pyc
      # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py d
      # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py
      # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py w
      # trying C:\Python25\lib \site-packages\_mydll pythonmodule.py c
      # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyd
      # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.py
      # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyw
      # trying C:\Python25\lib \site-packages\win32\ _mydllpythonmod ule.pyc
      # trying C:\Python25\lib \site-packages\win32\ lib
      \_mydllpythonmo dule.pyd
      # trying C:\Python25\lib \site-packages\win32\ lib\_mydllpytho nmodule.py
      # trying C:\Python25\lib \site-packages\win32\ lib
      \_mydllpythonmo dule.pyw
      # trying C:\Python25\lib \site-packages\win32\ lib
      \_mydllpythonmo dule.pyc
      # trying C:\Python25\lib \site-packages\Python win
      \_mydllpythonmo dule.pyd
      # trying C:\Python25\lib \site-packages\Python win\_mydllpytho nmodule.py
      # trying C:\Python25\lib \site-packages\Python win
      \_mydllpythonmo dule.pyw
      # trying C:\Python25\lib \site-packages\Python win
      \_mydllpythonmo dule.pyc
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      ImportError: No module named _mydllpythonmod ule
      >
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.9 (MingW32)
      Comment: Using GnuPG with Mozilla -http://enigmail.mozdev .org
      >
      iEYEARECAAYFAki JNGwACgkQLMI5fn dAv9hykgCcDf4cT ZU0iDo+ELQ5aFGs 9FIO
      8GEAn3+egrPDtNr lbsssqti8YeZXXI eM
      =q31k
      -----END PGP SIGNATURE-----

      Comment

      • Fredrik Lundh

        #4
        Re: import dll instead of pyd

        jrh wrote:
        Yes it is in the same directory. The problem is it does not seem to
        look for dll's at all. So is this by design, or am I missing
        something?
        looks like that was removed in 2.5; from Misc/NEWS:

        - On Windows, .DLL is not an accepted file name extension for
        extension modules anymore; extensions are only found if they
        end in .PYD.

        which is easily confirmed:

        Python 2.4.3
        >>import imp
        >>imp.get_suffi xes()
        [('.pyd', 'rb', 3), ('.dll', 'rb', 3), ('.py', 'U', 1),
        ('.pyw', 'U', 1), ('.pyc', 'rb', 2)]

        Python 2.5
        >>import imp
        >>imp.get_suffi xes()
        [('.pyd', 'rb', 3), ('.py', 'U', 1), ('.pyw', 'U', 1),
        ('.pyc', 'rb', 2)]

        (the DLL support was a compatibility thing anyway, so I guess removing
        it after 10+ years is a reasonable thing to do...)

        </F>

        Comment

        Working...