Could not import 'btree' in MicroPython 1.9.4

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

Could not import 'btree' in MicroPython 1.9.4

Post by lnsri22 » Mon Mar 18, 2019 10:54 am

Hello EveryOne!!

When I try to import 'btree' module in my pyboardv1.1 running MicroPython 1.9.4, I get this import error stating the absence of the module 'btree'


What am I missing?

Any help is greatly appreciated!!
lnsri22 :)

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Could not import 'btree' in MicroPython 1.9.4

Post by jickster » Mon Mar 18, 2019 2:19 pm

It’s probably not compiled in; you need to define MICROPY_PY_BTREE


Sent from my iPhone using Tapatalk Pro

lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

Re: Could not import 'btree' in MicroPython 1.9.4

Post by lnsri22 » Tue Mar 19, 2019 5:05 am

Thanks jickster for the quick reply there!!


Let me give a try and update!!
lnsri22 :)

Picasso
Posts: 39
Joined: Fri Mar 22, 2019 12:13 pm

Re: Could not import 'btree' in MicroPython 1.9.4

Post by Picasso » Mon Mar 25, 2019 4:45 pm

Any progress? I couldn't help but notice that BTree is written in c. You probably need to set the right flag, recompile the micropython codebase and create your new firmware for your case.
>>> extmod/modbtree.c
Line 35: #if MICROPY_PY_BTREE

So, set the flag and recompile?

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Could not import 'btree' in MicroPython 1.9.4

Post by jickster » Mon Mar 25, 2019 4:49 pm

Yes that’s correct.


Sent from my iPhone using Tapatalk Pro

Picasso
Posts: 39
Joined: Fri Mar 22, 2019 12:13 pm

Re: Could not import 'btree' in MicroPython 1.9.4

Post by Picasso » Mon Mar 25, 2019 7:16 pm

Humm ... time for btree module in pure python? Than the user could simply copy the module and continue with this project.
The guys who want to have the c version, can still use the c version.

lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

Re: Could not import 'btree' in MicroPython 1.9.4

Post by lnsri22 » Tue Mar 26, 2019 7:30 am

Picasso wrote:
Mon Mar 25, 2019 4:45 pm
Any progress? I couldn't help but notice that BTree is written in c. You probably need to set the right flag, recompile the micropython codebase and create your new firmware for your case.
>>> extmod/modbtree.c
Line 35: #if MICROPY_PY_BTREE

So, set the flag and recompile?
Thanks Picasso!!

Your suggestion worked like a charm!!

Sorry for the delayed update by the way
lnsri22 :)

hlovatt
Posts: 68
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

Re: Could not import 'btree' in MicroPython 1.9.4

Post by hlovatt » Fri Aug 28, 2020 7:40 am

The docs don't mention that btree is not normally included in a build. Should the docs say btree not included or should the build include btree?

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

Re: Could not import 'btree' in MicroPython 1.9.4

Post by pythoncoder » Fri Aug 28, 2020 5:25 pm

Peter Hinch
Index to my micropython libraries.

hlovatt
Posts: 68
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

Re: Could not import 'btree' in MicroPython 1.9.4

Post by hlovatt » Sun Aug 30, 2020 5:32 am

Thanks. Have issued pull request for documentation noting availability.

Post Reply