[IronPython] Help me IronPython + pybluez + VBNET

Sebastian Urbanski sebaurbanski at gmail.com
Sat Aug 21 19:33:15 CEST 2010

Hello, i'm a student from Argentina

I am developing an application that send and receive SMS messages.

This works fine in Python + Pybluez, but when i want to execute this code
from VBNET, i have problems. Ironpython can't resolve the bluetooth import

I am using NET 2008, python 2.6, Iron python 2.6 and

Here i have a testing class "HelloWorl.py" to try to import package
bluetooth. The error result in NET is "global name 'discover_devices' is not

import clr
import sys
import bluetooth
import select
from prueba import HelloWorldVB
class HelloWorldIronPython(HelloWorldVB):
    def HelloWorld(self, name):
        return "Hello '" + name + "' from IronPython"
Bluetooth's package is installed in the following path:

I founded the function discover_devices and it is in bluez.py

If i try to import directly the bluez.py i have another error. Ironpython
not found the _bluetooth import.

import sys
import struct
import binascii
from btcommon import *
import _bluetooth as _bt
import array
import fcntl

Here my code for NET (solutions name is "prueba"):

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
Handles Button1.Click

Dim helloWorld As New HelloWorldVB()


Dim runtime As ScriptRuntime =

Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")

Dim pythonType As PythonType = scope.GetVariable(Of PythonType)(

helloWorld = CType(runtime.Operations.Invoke(pythonType), HelloWorldVB)


End Sub

Public Class HelloWorldVB

Public Overridable Function HelloWorld(ByVal name As String) As String

Return String.Format("Hello '{0}' from Visual Basic", name)

End Function

End Class

Any idea to import correctly the package bluetooth????


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100821/79f30521/attachment.html>

More information about the Ironpython-users mailing list