Skip to content

umqtt cannot import MQTTClient #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DonPavlov opened this issue Jan 10, 2018 · 3 comments
Closed

umqtt cannot import MQTTClient #250

DonPavlov opened this issue Jan 10, 2018 · 3 comments

Comments

@DonPavlov
Copy link

Using the latest esp32 micropython build. Dowloaded the latest umqtt with these commands:
upip.install('micropython-umqtt.simple')
upip.install('micropython-umqtt.robust')

But as soon as i want to follow even the simplest of examples and try this:

from umqtt.simple import MQTTClient
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name MQTTClient

but if i put the umqtt.simple lib just onto the main memomry of the esp32

ampy --port COM6 put C:\Users\xxxx\Downloads\simple.py

and use simple.py import MQTTClient it works.
so somehow something seems broken.

@oeichler
Copy link

I had exactly the same problem.
Digging around a little bit I found out that lib/umqtt/simple.py was simply empty:

f = open('lib/umqtt/simple.py')
f.read()

Probably the installation silently failed in any strange way...
Repeating upip.install('micropython-umqtt.simple') fixed the problem.

@dmurphydrtc
Copy link

dmurphydrtc commented Jun 1, 2018

Came across this issue today while using f/w esp32-20180511-v1.9.4.bin.
The contents of file simple.py in lib/umqtt was empty. I downloaded another copy of simple.py and used ampy put to re-install it - 'ampy --port COM7 put simple.py 'lib/umqtt/simple.pyuse'

This solved the problem. So I thought I had stuffed up the firmware or mqtt install but went through the
exercise a second & third time with the same result.

Solution....Use ampy to copy a version of simple.py from the micropython-lib - and continue with installation.
ampy --port COM7 put simple.py 'lib/umqtt/simple.py

"import network
import upip

sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect("Wifi SSID", "Wifi password")

upip.install('micropython-umqtt.simple')
upip.install('micropython-umqtt.robust')"

PS - Followed this procedure to install BME280 and mqtt on esp32.

https://github.com/gloveboxes/ESP32-MicroPython-BME280-MQTT-Sample

@Mack13Podwin
Copy link

I am Using NodeMCU esp board with newest version of micropython firmware and my solution to this problem is to load simple.py with WEBREPL and then use

uos.mkdir()

and

uos.rename()

to put this file to lib/umqtt.

@DonPavlov DonPavlov closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants