Seite 1 von 1

Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 11:52
von PythonFish
Hallo,

ich habe ein Problem bei der Installation von einem Modul (WiiYourself http://wiiyourself.gl.tter.org/).
Ich kann mein Modul problemlos mit dem Befehl "setup.py install" in meiner normalen Python-Umgebung(C:/Python32) installieren und verwenden.

Jedoch brauche ich dieses Modul in einer embedded Python-version (Blender). Die Datei setup.py enthält folgenden Code:

Code: Alles auswählen

#!/usr/bin/env python

from distutils.core import setup, Extension

exts = Extension('_wiimote', sources=['wiimote_wrap.cxx', '../wiimote.cpp'])

setup (name = 'wiimote',
       version = '1.15RC2',
       author      = "gl.tter, nneonneo",
       description = """WiiYourself! python bindings""",
       ext_modules = [exts],
       py_modules = ["wiimote"],
       )
Kann mir jemand sagen was dieses Skript genau macht?
Wie bekomme ich dieses Modul für mein embedded Python installiert?

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 12:20
von BlackJack
@PythonFish: Man muss die ``setup.py`` normalerweise mit dem Python aufrufen, für dass man installieren möchte. Kannst ja mal schauen ob das Blender-Python auch irgendwo einen Interpreter hat, den man direkt starten kann.

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 12:26
von PythonFish
Folgendes bekomme ich in der Blender-bounded Python-version:

Code: Alles auswählen

PYTHON INTERACTIVE CONSOLE 3.2 (r32:88445, Mar  2 2011, 16:59:21) [MSC v.1500 64 bit (AMD64)]

Command History:     Up/Down Arrow
Cursor:              Left/Right Home/End
Remove:              Backspace/Delete
Execute:             Enter
Autocomplete:        Ctrl+Space
Ctrl +/-  Wheel:     Zoom
Builtin Modules:     bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *

>>> import sys
>>> sys.path
['C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\scripts\\addons', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\scripts\\startup', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\scripts\\modules', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\python', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\python32.zip', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\python\\DLLs', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\python\\lib', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60RC2-windows64\\2.59\\scripts\\addons\\modules']

>>> 
Hilft das weiter?

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 13:38
von PythonFish
ich habe nun den Pfad meiner Python-Umgebung (C:\\Python32\\lib\\site-packages) inden das Modul installiert wurde dem sys.path der Blender-bounded Python version hinzugefügt

Leider bekomme ich nun folgenden Fehler:

Code: Alles auswählen

>>> import wiimote
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "C:\Python32\lib\site-packages\wiimote.py", line 26, in <module>
    _wiimote = swig_import_helper()
  File "C:\Python32\lib\site-packages\wiimote.py", line 22, in swig_import_helper
    _mod = imp.load_module('_wiimote', fp, pathname, description)
ImportError: DLL load failed: %1 ist keine zulässige Win32-Anwendung.
Was fehlt im hier nun noch ?

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 13:50
von deets
Sieht so aus als ob du 64 und 32-bit-Code mischst. Das kann nicht funktionieren.

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 13:59
von PythonFish
ok das heisst ich sollte mal sicherstellen das sowohl meien lokale python installation, als auch swig und blender alles 32 bit ist und dann nchmals versuchen, oder?

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 14:06
von deets
32 oder 64 bit, eines von beiden, ja. Ich vermute mal, dass 32bit die bessere Idee ist.

Re: Installation von Modul

Verfasst: Mittwoch 19. Oktober 2011, 14:53
von PythonFish
Will irgendwie trotzdem noch nicht ganz:

Hier die Konsole von meiner normalen Python-Umgebung:

Code: Alles auswählen

C:\Users\x>python
Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\Windows\\system32\\python32.zip', 'C:\\Python32\\DLLs', 'C:\\Python32\\lib', 'C:\\Python32', 'C:\\Python32\\lib\\site-packages']
>>>
>>>
>>> import wiimote
>>>
Und hier die Blender-bounded Pythonausgabe:

Code: Alles auswählen


PYTHON INTERACTIVE CONSOLE 3.2 (r32:88445, Mar  4 2011, 02:13:51) [MSC v.1500 32 bit (Intel)]

Command History:     Up/Down Arrow
Cursor:              Left/Right Home/End
Remove:              Backspace/Delete
Execute:             Enter
Autocomplete:        Ctrl+Space
Ctrl +/-  Wheel:     Zoom
Builtin Modules:     bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *

>>> import sys
>>> sys.path.append("C:\\Python32\\lib\\site-packages")
>>> sys.path
['C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\scripts\\addons', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\scripts\\startup', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\scripts\\modules', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\python', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\python32.zip', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\python\\DLLs', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\python\\lib', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32', 'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\2.60\\scripts\\addons\\modules', 'C:\\Python32\\lib\\site-packages']

>>> 
>>> 
>>> import wiimote
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "C:\Python32\lib\site-packages\wiimote.py", line 26, in <module>
    _wiimote = swig_import_helper()
  File "C:\Python32\lib\site-packages\wiimote.py", line 22, in swig_import_helper
    _mod = imp.load_module('_wiimote', fp, pathname, description)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

>>> 

Re: Installation von Modul

Verfasst: Donnerstag 20. Oktober 2011, 21:07
von PythonFish
Wow bin echt am Verzweifeln. Wo könnte hier noch der Fehler liegen ? (Habe wie gesagt dem blender python sys.path NUR C:\\Python32\\Lib\\site-package) hinzugefügt

1. Hier die Ausgabe zur Installation des Moduls:

Code: Alles auswählen

C:\script\WiiYourself!_1.15\Python>setup.py install
running install
running build
running build_py
creating build
creating build\lib.win32-3.2
copying wiimote.py -> build\lib.win32-3.2
running build_ext
building '_wiimote' extension
creating build\temp.win32-3.2
creating build\temp.win32-3.2\Release
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python32\include -IC:\Python32\PC /Tpwiimote_wrap.cxx /Fobuild\
temp.win32-3.2\Release\wiimote_wrap.obj
wiimote_wrap.cxx
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++-Handler verwendet, aber Entladesemantik ist nicht aktiviert. Geben Sie /EH
sc an.
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python32\include -IC:\Python32\PC /Tp../wiimote.cpp /Fobuild\te
mp.win32-3.2\Release\../wiimote.obj
wiimote.cpp
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python32\libs /LIBPATH:C:\Python32\PCbuild /EXPORT:PyInit__wii
mote build\temp.win32-3.2\Release\wiimote_wrap.obj build\temp.win32-3.2\Release\../wiimote.obj /OUT:build\lib.win32-3.2\_wiimote.pyd /IMPLIB:build\temp.win32-3.2\Release\
_wiimote.lib /MANIFESTFILE:build\temp.win32-3.2\Release\_wiimote.pyd.manifest
   Bibliothek "build\temp.win32-3.2\Release\_wiimote.lib" und Objekt "build\temp.win32-3.2\Release\_wiimote.exp" werden erstellt.
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest build\temp.win32-3.2\Release\_wiimote.pyd.manifest -outputresource:build\lib.win32-3.2\_wiimote
.pyd;2
running install_lib
copying build\lib.win32-3.2\_wiimote.pyd -> C:\Python32\Lib\site-packages
byte-compiling C:\Python32\Lib\site-packages\wiimote.py to wiimote.pyc
running install_egg_info
Removing C:\Python32\Lib\site-packages\wiimote-1.15RC2-py3.2.egg-info
Writing C:\Python32\Lib\site-packages\wiimote-1.15RC2-py3.2.egg-info
2. Hier das erzeugte Build-Verzeichnis:

Bild
Bild
Bild
Bild

3. Mein Ordner site-packages sieht wie folgt aus:

Bild
Bild

Re: Installation von Modul

Verfasst: Donnerstag 20. Oktober 2011, 23:25
von deets
Ich benutze kein Windows, darum kann ich da nur beschraenkt viel zu sagen. Aber was mich schon wundert: warum baust du eine Extension mit einem externen Python, um sie mit dem Blender-Interpreter dann laufen lassen zu wollen? Hat Blender keine eigene Python-EXE? Wenn nicht, dann solltest du rausbekommen, wie genau die Python-DLL dafuer gebaut wurde, und dir im Zweifelsfall ein kompatibles Python selbst bauen. Mehr faellt mir dann auch nicht ein, ohne tiefere Kenntnisse vom Windows-Linker & Loader.

Re: Installation von Modul

Verfasst: Freitag 21. Oktober 2011, 00:53
von ms4py
Versuch mal den Build über den Interpreter von Blender zu starten:

Code: Alles auswählen

subprocess.call([sys.executable, 'setupy.py', 'build'])

Re: Installation von Modul

Verfasst: Freitag 21. Oktober 2011, 07:38
von PythonFish
deets hat geschrieben:Ich benutze kein Windows, darum kann ich da nur beschraenkt viel zu sagen. Aber was mich schon wundert: warum baust du eine Extension mit einem externen Python, um sie mit dem Blender-Interpreter dann laufen lassen zu wollen? Hat Blender keine eigene Python-EXE? Wenn nicht, dann solltest du rausbekommen, wie genau die Python-DLL dafuer gebaut wurde, und dir im Zweifelsfall ein kompatibles Python selbst bauen. Mehr faellt mir dann auch nicht ein, ohne tiefere Kenntnisse vom Windows-Linker & Loader.
Ja das Problem ist das diese Blender-gebunde Python-Umgebung keine eigene Exe besitzt. Mal schaun ob ich es hinbekomme meine Python-Umgebung in Blender zu verwenden.
Ich hatte ursprünglich auch extra drauf geachtet das ich in beiden Python-Umgebungen dieselbe Version habe (3.2).

Re: Installation von Modul

Verfasst: Freitag 21. Oktober 2011, 08:29
von BlackJack
@PythonFish: Das ist doch sicher kein Problem was nur Du alleine hast. Ein weiteres Python-Modul mit C-Code wollten vor Dir sicher schon andere für Blender installieren. Also sollte es dazu in den entsprechenden Foren auch schon Fragen und Antworten geben. Vielleicht gibt es ja sogar einen offiziell dokumentierten Weg das zu tun.

Re: Installation von Modul

Verfasst: Freitag 21. Oktober 2011, 16:42
von ms4py
Was gibt denn `sys.executable` in der Blender-Konsole zurück? Meinen Vorschlag von oben bereits versucht, ob das funktioniert?

Re: Installation von Modul

Verfasst: Samstag 22. Oktober 2011, 14:28
von PythonFish
Hier der Output

Code: Alles auswählen

PYTHON INTERACTIVE CONSOLE 3.2 (r32:88445, Mar  4 2011, 02:13:51) [MSC v.1500 32 bit (Intel)]

Command History:     Up/Down Arrow
Cursor:              Left/Right Home/End
Remove:              Backspace/Delete
Execute:             Enter
Autocomplete:        Ctrl+Space
Ctrl +/-  Wheel:     Zoom
Builtin Modules:     bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *

>>> import sys
>>> sys.executable
'C:\\Users\\x\\Desktop\\dis\\blender-2.60-windows32\\blender.exe'
Nun weiß ich auch warum er nicht verusch hat, das Modul zu installieren sondern immer eine neue Blender Instanz geöffnet hat :D

Re: Installation von Modul

Verfasst: Samstag 22. Oktober 2011, 16:58
von lunar
@PythonFish: Du könntest versuchen, "setup.py" über den interaktiven Interpreter auszuführen (ohne Gewähr!):

Code: Alles auswählen

>>> os.chdir('C:\\script\\WiiYourself!_1.15\\Python>')
>>> sys.argv = ['setup.py', 'install']
>>> execfile('setup.py', {'__name__': '__main__'})

Re: Installation von Modul

Verfasst: Samstag 22. Oktober 2011, 18:43
von PythonFish
ging leider nicht da er das distutils.core module nicht kennt

Code: Alles auswählen

>>> import sys
>>> import os
>>> os.chdir('C:\\script\\WiiYourself!_1.15\\Python')
>>> sys.argv = ['setup.py', 'install']
>>> execfile('setup.py', {'__name__': '__main__'})
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
NameError: name 'execfile' is not defined

>>> exec(open('setup.py').read(), {'__name__': '__main__'})
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "<string>", line 3, in <module>
ImportError: No module named distutils.core
Hab jetzt mal versucht den Sys.path der Blender-bounded Python Umgebung mit "C:\Python32\Lib\distutils" zu erweitern - hat leider nicht geholfen

edit:
das setup.py file sieht so aus:

Code: Alles auswählen

#!/usr/bin/env python

from distutils.core import setup, Extension

exts = Extension('_wiimote', sources=['wiimote_wrap.cxx', '../wiimote.cpp'])

setup (name = 'wiimote',
       version = '1.15RC2',
       author      = "gl.tter, nneonneo",
       description = """WiiYourself! python bindings""",
       ext_modules = [exts],
       py_modules = ["wiimote"],
       )

Re: Installation von Modul

Verfasst: Samstag 22. Oktober 2011, 18:52
von PythonFish

Code: Alles auswählen

>>> sys.path.append('C:\\Python32\\lib')
>>> exec(open('setup.py').read(), {'__name__': '__main__'})
running install
running build
running build_py
running build_ext
running install_lib
copying build\lib.win32-3.2\wiimote.py -> C:\Users\x\Desktop\dis\blender-2.60-windows32\2.60\python\Lib\site-packages
copying build\lib.win32-3.2\_wiimote.pyd -> C:\Users\x\Desktop\dis\blender-2.60-windows32\2.60\python\Lib\site-packages
byte-compiling C:\Users\x\Desktop\dis\blender-2.60-windows32\2.60\python\Lib\site-packages\wiimote.py to wiimote.pyc
running install_egg_info
Writing C:\Users\x\Desktop\dis\blender-2.60-windows32\2.60\python\Lib\site-packages\wiimote-1.15RC2-py3.2.egg-info

>>> import wiimote
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "C:\Users\x\Desktop\dis\blender-2.60-windows32\2.60\python\lib\site-packages\wiimote.py", line 26, in <module>
    _wiimote = swig_import_helper()
  File "C:\Users\x\Desktop\dis\blender-2.60-windows32\2.60\python\lib\site-packages\wiimote.py", line 22, in swig_import_helper
    _mod = imp.load_module('_wiimote', fp, pathname, description)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
geht wohl leider auch nicht

Re: Installation von Modul

Verfasst: Sonntag 23. Oktober 2011, 13:56
von lunar
@PythonFish: Ich glaube, dann ist spätestens jetzt der Punkt gekommen, an welchem Du Dich an die Blender-Entwickler oder zumindest an die Blender-Community wenden solltest.

Re: Installation von Modul

Verfasst: Sonntag 23. Oktober 2011, 16:28
von PythonFish
alles klar!

Vielen Dank :)