Seite 1 von 1
dll Import
Verfasst: Freitag 5. Juni 2009, 10:25
von mayx
Hey,
ich hab gestern das erstemal eine dll in die Hand bekommen.
Die dll ist bei einen Windowsprogramm dabei und ich hab sie in
meinen Python2.5-Ordner kopiert.
>>> import D3 as D3
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import D3 as D3
ImportError: No module named D3
>>>
Was habe ich falsch gemacht bzw. vergessen?
Danke !
EDIT:
ich habe es mal so versuch zu laden:
>>> D3 = imp.load_dynamic('minx', os.getcwd() + '\\D3.dll')
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
minx = imp.load_dynamic('minx', os.getcwd() + '\\D3.dll')
ImportError: Module use of python24.dll conflicts with this version of Python.
leider auch kein erfolg, python24.dll wird wohl benötigt.
heißt das ich python2.4 nutzen muß oder kann ich auch einfach nur die dll in meinen python2.5-Ordner kopieren?
Nochmal Danke
Verfasst: Freitag 5. Juni 2009, 10:32
von EyDu
Wahrscheinlich suchst du das ctypes-Modul.
Verfasst: Freitag 5. Juni 2009, 10:36
von mayx
ich dachte das Modul ist in 2.5 schon eingebaut.
Der Ordner is richtig für die dll?
Verfasst: Freitag 5. Juni 2009, 10:47
von cofi
Richtig. EyDu meint aber, dass du es auch benutzen sollst.
Verfasst: Freitag 5. Juni 2009, 11:21
von mayx
Ah....
aber ich steh leider immer noch auf Schlauch ;(
Code: Alles auswählen
>>> from ctypes import *
>>> print windll.kernel32
<WinDLL 'kernel32', handle 7c800000 at 1177a50>
geht, aber ich bekomme immer noch die selbe Fehlermeldung....
Code: Alles auswählen
>>> import D3
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import D3
ImportError: No module named D3
bzw.
Code: Alles auswählen
>>> import imp
>>> import os
>>> minx = imp.load_dynamic('minx', os.getcwd() + '\\D3.dll')
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
minx = imp.load_dynamic('minx', os.getcwd() + '\\D3.dll')
ImportError: Module use of python24.dll conflicts with this version of Python.
Verfasst: Freitag 5. Juni 2009, 11:25
von EyDu
Du hast aber schon in die
Dokumentation zu ctypes geschaut?
Verfasst: Freitag 5. Juni 2009, 11:27
von cofi
Wobei ich bei der Fehlermeldung vermute, dass die Bibliothek für Python 2.4 kompiliert wurde..
Verfasst: Freitag 5. Juni 2009, 12:36
von birkenfeld
Ab Python 2.5 müssen alle Extensions Dateinamen mit .pyd haben.
Verfasst: Freitag 5. Juni 2009, 13:08
von mayx
Cool.
Also Doku hab ich natürlich angeguckt, da hab ich auch das mit windll.kernel her.
Ich hab jetzt activepython 2.4 runtergeladen und installiert.
Stören sich die Python-Versionen sich gegenseitig?
Hab auf C:\python24 und C:\python25
Nun gehe ich unter "ActiveState ActivePython 2.4" auf "Python Interactive Shell"
und gebe "import D3" ein. Es scheint zu klappen da keine Fehlermeldung erscheint. Komischerweise werden aber nicht alle Methoden die die Bibiothek hat unterstützt bzw. kann ich aufrufen.
Viel Dank für eure Hilfe ich such und teste mal weiter.
Für Ideen bin ich sehr dankbar.
Verfasst: Freitag 5. Juni 2009, 13:12
von cofi
Das nebeneinander ist auf einem Windowssystem absolut kein Problem, da das Windowssystem kein Python nutzt. Einzig die Zuordnung zur jeweiligen Version könnte ein Problem sein, d.h. die Version mit der standardmäßig Skripte ausgeführt werden.
Verfasst: Freitag 5. Juni 2009, 13:25
von mayx
Ja, das hab ich mir auch schon gedacht.
Das Programm, das ich nutzte, nutz selber wiederrum eine python.dll
Bekommt man vielleicht Python2.4 auch als dll ?
Danke!
Verfasst: Freitag 5. Juni 2009, 13:51
von cofi
Da ich kein Windows benutze gibts keine Garantie: Jede Pythonversion bringt eine DLL mit, schau mal im Python- bzw Systemordner.
Vielleicht findest du auch was in den beiden Links:
*
http://www.python.org/doc/2.4.4/ext/ext.html
*
http://www.python.org/doc/2.4.4/api/api.html
Verfasst: Freitag 5. Juni 2009, 15:17
von mayx
Vielen Dank!!!
Es klappt. Puh.