error when trying to use "from . import"

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
corleo
Posts: 2
Joined: Sun Nov 13, 2016 4:55 am

error when trying to use "from . import"

Post by corleo » Sun Nov 13, 2016 5:23 am

Today I compiled 'MicroPython v1.8.6-9-g30cfdc2 on 2016-11-13' to Esp and installed uqmtt.robust using upip. This installation created files robust.py and simple.py at /lib/umqtt/ dir as expected. But when I tried to import robust I got:

>>> from umqtt import robust
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/umqtt/robust.py", line 4, in <module>
AttributeError: 'module' object has no attribute 'MQTTClient'

and this is because of robust.py line 2: 'from . import simple'.
>>> from . import simple
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: __main__

It seams that mycropython doesn't recognize this dot as a current directory because this way I succeeded to import robust.py:
>>> from umqtt import simple
>>> from umqtt import robust

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: error when trying to use "from . import"

Post by pythoncoder » Sun Nov 13, 2016 8:08 am

I suggest you raise an issue against micropython-lib https://github.com/micropython/micropython-lib.
Peter Hinch
Index to my micropython libraries.

Post Reply