Page 1 of 1

error when trying to use "from . import"

Posted: Sun Nov 13, 2016 5:23 am
by corleo
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

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

Posted: Sun Nov 13, 2016 8:08 am
by pythoncoder
I suggest you raise an issue against micropython-lib https://github.com/micropython/micropython-lib.