4

I'm using the module azure.servicebus.

from azure.servicebus import ServiceBusService , Message , Queue

When I use it in an external made script and run it, it works and gives no errors.

When I import the module in my init.py file and run the flask server. I get this error:

Traceback (most recent call last):
File "__init__.py", line 35, in <module>
app = server.OpSoRoApplication()
File "/home/pi/OnoSW/server.py", line 101, in __init__
plugin = self.plugin_source.load_plugin(plugin_name)
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 272, in load_plugi           n
globals(), {}, ['__name__'])
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
File "/home/pi/OnoSW/./apps/assistant/__init__.py", line 29, in <module>
import IFTTT
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
File "/home/pi/OnoSW/IFTTT.py", line 1, in <module>
from azure.servicebus import ServiceBusService , Message , Queue
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/__init__.py", line 39,            in <module>
from .servicebusservice import ServiceBusService
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py",            line 46, in <module>
from ._common_serialization import (
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/_common_serialization.           py", line 31, in <module>
from xml.sax.saxutils import escape as xml_escape
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
File "/usr/lib/python2.7/xml/sax/__init__.py", line 22, in <module>
from xmlreader import InputSource
File "/usr/local/lib/python2.7/dist-packages/pluginbase.py", line 404, in plugin_imp           ort
fromlist, level)
ImportError: No module named xmlreader

Can someone help to figure out how I can make it possible to be able to import the azure.servicebus module?

Thanks

3 Answers 3

2

ServiceBusService is deprecated in v7.0.0 https://pypi.org/project/azure-servicebus/7.0.0/

from azure.servicebus import ServiceBusClient, ServiceBusMessage

Sign up to request clarification or add additional context in comments.

Comments

1

For people stumbling upon this question now having the same problem:

Azure SDK updates often does and has introduced breaking changes: 0.2 -> 0.5:

# From azure.servicebus import ServiceBusService <- This will now raise an ImportError
from azure.servicebus.control_client import ServiceBusService

0.5 -> 7.0.0

#from azure.servicebus import ServiceBusService <-- Now outdated
from azure.servicebus.management import ServiceBusAdministrationClient 

This is however not enough: Make sure to check further API changes in this migration guide: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/servicebus/azure-servicebus/migration_guide.md

1 Comment

doesn't work : "ImportError: No module named control_client" May be they changed again.
0

There is a similar SO thread answered by me, which I think you can refer to, and try to solve the issue, please see Unable to use azure SDK in Python.

Meanwhile, per my experience, I suggest that you need to check whether the name conflict with xmlreader for python modules and scripts exists, please refer to the answer for the SO thread ImportError: cannot import name Session, when using Azure SDK.

Hope it helps. Any update, please feel free to let me know.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.