← Back to team overview

mqtt-users team mailing list archive

Re: python mosquitto 0.10 on windows.

 

Hi Karl,

(repeating some irc conversation)

My experience is now that the dll needs to be in a path that is in the
Windows %PATH% variable - so putting it in e.g. C:\Windows\System32
would work, or adding the path with mosquitto.dll to %PATH% should
also work.

I'm sure I did have it working in site-packages but this doesn't
appear to be the case.

Cheers,

Roger

On Wed, May 11, 2011 at 1:40 PM, karlp <karlp@xxxxxxxxxxxx> wrote:
>
> Hi,
>
> I'm trying to use mosquitto 0.10 with python 2.7 on windows.  I can use the mosquitto_sub.exe commands quite happily,
> and see the data, but there seems to be a ctypes problem finding the mosquitto.dll when I try and use the python
> bindings.  (Full stack trace below)
>
> It seems that ctypes.util.find_library("mosquitto") is failing.  I found a related post in the comments at
> http://mosquitto.org/2010/11/version-0-9-released/  and the reply was that mosquitto.dll needed to be put somewhere on
> the path.
>
> I've tried putting the dll in just about everywhere in sys.path, to no avail.  I've put it in C:\tools\Python27\Lib\site-packages
> which is where the mosquitto.py ended up, following Roger's comments... "I know it works if you put in
> C:\Python27\lib\site-packages\ (assuming Python 2.7 and that’s where mosquitto.py ended up) but I’m not really sure what
> the proper way to deal with this is."
>
> but that still doesn't work for me.  Any ideas?
>
> C:\srcx\python\mqtt_debug\src>python
> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import mosquitto
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "c:\tools\python27\lib\site-packages\mosquitto.py", line 408, in <module>
>
>    _libmosq = cdll.LoadLibrary(find_library("mosquitto"))
>  File "c:\tools\python27\lib\ctypes\__init__.py", line 431, in LoadLibrary
>    return self._dlltype(name)
>  File "c:\tools\python27\lib\ctypes\__init__.py", line 353, in __init__
>    self._handle = _dlopen(self._name, mode)
> TypeError: expected string or Unicode object, NoneType found
>>>> import ctypes.util
>>>> ctypes.util.find_library("mosquitto")
>>>> print ctypes.util.find_library("mosquitto")
> None
>>>> print ctypes.util.find_library("mosquitto.dll")
> None
>>>> import sys
>>>> print sys.path
> ['', 'C:\\windows\\system32\\python27.zip', 'c:\\tools\\python27\\DLLs', 'c:\\to
> ols\\python27\\lib', 'c:\\tools\\python27\\lib\\plat-win', 'c:\\tools\\python27\
> \lib\\lib-tk', 'c:\\tools\\python27', 'c:\\tools\\python27\\lib\\site-packages']
>
>
> I've tried DLLs, the root directory, the current source directory, lib\site-packages, lib and libs, but no luck yet.
>
> Sincerely,
> Karl P
>
> _______________________________________________
> Mailing list: https://launchpad.net/~mqtt-users
> Post to     : mqtt-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~mqtt-users
> More help   : https://help.launchpad.net/ListHelp
>


References