Import micropython-lib

Discussion related to "under the hood" OpenMV topics.
mannybranden7
Posts: 7
Joined: Mon Dec 11, 2017 10:25 pm

Import micropython-lib

Postby mannybranden7 » Mon Dec 11, 2017 10:31 pm

I am having some trouble importing a certain library module from micropython-lib on to the OpenCam M7 board. I am trying to use the pipe() function that is included in the OS module of the micropython-lib. I went through the micropython documentation to learn how to download and import the modules but for some reason, it is not working. The error I keep getting is that it cant find the "pipe_" function which is located in the OS folder of micropython-lib/os/__init__.py.

If anyone knows how to import these libraries, can you please explain how. Or is this not possible? I am using a windows laptop with the OpenMV Cam M7.

Thank you in advance!
User avatar
kwagyeman
Posts: 1752
Joined: Sun May 24, 2015 2:10 pm

Re: Import micropython-lib

Postby kwagyeman » Tue Dec 12, 2017 12:40 am

Hi, where did you place the module?

It needs to be like:

"/pipe/__init__.py"
or
"/pipe.py"

On the SD Card or flash FS.

Then in python you can do:

import pipe
Nyamekye,
mannybranden7
Posts: 7
Joined: Mon Dec 11, 2017 10:25 pm

Re: Import micropython-lib

Postby mannybranden7 » Tue Dec 12, 2017 4:04 pm

The module is located under the "os" directory called "__init__.py".

When I download the library module and import it into the sdcard it is like this: "/os/__init__.py" and I "import os".

I know there is another import for "os" so I renamed "os" to "oslib" and imported it like that but I still get the "pipe_" error. I tried importing the modules that "__init__.py" imports into its own module but it still doesn't work.

Here are some screenshots to show my setup I changed according to your procedures but I still get same error:
Pipe Function .PNG
Pipe Function .PNG (29.22 KiB) Viewed 419 times
After running the code above, I get this error from the __init__.py module
Pipe Function Error .PNG
Pipe Function Error .PNG (96.64 KiB) Viewed 419 times
Pipe Function Error 2 .PNG
Pipe Function Error 2 .PNG (38.75 KiB) Viewed 417 times
SDCard directory.PNG
SDCard directory.PNG (5.99 KiB) Viewed 419 times
SDCard pipe directory.PNG
SDCard pipe directory.PNG (4.87 KiB) Viewed 419 times
Here is the module I am looking to import:

https://github.com/micropython/micropyt ... ster/os/os

Do I have to import the whole "micropython-lib" library for it to work so that "/os/__init__.py" can work since it imports other files into its own module?

Thank you for your help!
User avatar
iabdalkader
Posts: 443
Joined: Sun May 24, 2015 3:53 pm

Re: Import micropython-lib

Postby iabdalkader » Tue Dec 12, 2017 7:34 pm

That's because there's no libc to load, there are no FDs and there's only a single process running anyway. The camera runs baremetal (it's Not Unix/Linux based).
Screenshot from 2017-12-13 02-22-40.png
Screenshot from 2017-12-13 02-22-40.png (64.56 KiB) Viewed 413 times
mannybranden7
Posts: 7
Joined: Mon Dec 11, 2017 10:25 pm

Re: Import micropython-lib

Postby mannybranden7 » Tue Dec 12, 2017 7:42 pm

Oh okay I see. I am sorry I didn't make that connection before.

Thank you for such a quick reply.
User avatar
kwagyeman
Posts: 1752
Joined: Sun May 24, 2015 2:10 pm

Re: Import micropython-lib

Postby kwagyeman » Tue Dec 12, 2017 8:29 pm

Oh, yeah, alot of the MPlib stuff is for the unix port of MicroPython.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests