pombreda / pybluez

Automatically exported from code.google.com/p/pybluez
GNU General Public License v2.0
0 stars 0 forks source link

Problems working with WIDCOMM stack on MS Windows XP #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
How to reproduce the problem:
1. I assume that you have bluetooth hardware working properly with the
WIDCOMM stack, You have installed correctly PyBluez and You are running
Windows XP.
2. You try to run code using PyBluez. We have a perfect example in the
"inquiry.py" file which is downloadable from the Documentation page in the
official site. Links following:
  >http://org.csail.mit.edu/pybluez/examples-0.7/inquiry.txt
  >http://org.csail.mit.edu/pybluez/docs.html

The output we normally expect is something like:
C:\Documents and Settings\rik\Desktop\PythonTests>inquiry.py
performing inquiry...
found 1 devices
  Z310i - 00:1C:A4:AB:21:7E

What we obtain instead is the following error:
C:\Documents and Settings\rik\Desktop\PythonTests>inquiry.py
Traceback (most recent call last):
  File "C:\Documents and Settings\rik\Desktop\PythonTests\inquiry.py", line
8, i
n <module>
    import bluetooth
  File "C:\Programmi\Python25\Lib\site-packages\bluetooth\__init__.py",
line 11,
 in <module>
    import _msbt
ImportError: DLL load failed: Impossibile trovare il modulo specificato(*).

(*)The italian phrase means "Impossible to find the specified module"

Why this happens:
Well, I found that in the code contained in the file "__init__.py" which
belongs to PyBluez libraries there is a passage where, without any
conditions, the module "_msbt" is requested with an include command.
In other words, the code, as it comes, when it finds that I am running
Windows it supposes unconditionally that I'm also using the Microsoft stack.
Since I am not using that stack and I am using the WIDCOMM's instead, when
"__init__.py" tries to include "_msbt" we have the error. Consequently the
execution is stopped and the code after that line, which detects the
WIDCOMM stack, is never run.

How to solve the problem:
The solution is very simple. Just locate the file "__init__.py" directory
"%YourPythonDir%\Lib\site-packages\bluetooth". Open that file, locate the
following two lines (should be line 11 and 12):
    import _msbt
    _msbt.initwinsock ()
and simply comment them like so:
    #import _msbt
    #_msbt.initwinsock ()
Save the file and exit.
Now everything should work fine.

Version and hardware details:
Windows XP Professional Service Pack 1
Python 2.5.1
PyBluez 0.15 (win32-py2.5)
WIDCOMM stack 1.4.2.8
D-Link DBT-120 Bluetooth usb key

******************************************************************
The modified version of "__init__.py" is attached. Be sure to make a backup
copy of your copy of the "__init__.py" file before moving it to your
PyBluez folder.

Riccardo Stecca

Original issue reported on code.google.com by riccardo...@gmail.com on 20 Nov 2008 at 1:24

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Riccardo,

Thanks for the detailed report.

Original comment by ashu...@gmail.com on 22 Nov 2008 at 5:58

GoogleCodeExporter commented 9 years ago
This should be fixed in 0.16

Original comment by ashu...@gmail.com on 17 Mar 2009 at 5:14

GoogleCodeExporter commented 9 years ago
Great! Thanks for fixing it.

Original comment by riccardo...@gmail.com on 17 Mar 2009 at 9:09