Page 1 of 1

Import micropython-lib

Posted: Mon Dec 11, 2017 10:31 pm
by mannybranden7
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!

Re: Import micropython-lib

Posted: Tue Dec 12, 2017 12:40 am
by kwagyeman
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

Re: Import micropython-lib

Posted: Tue Dec 12, 2017 4:04 pm
by mannybranden7
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 2059 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 2059 times
Pipe Function Error 2 .PNG
Pipe Function Error 2 .PNG (38.75 KiB) Viewed 2057 times
SDCard directory.PNG
SDCard directory.PNG (5.99 KiB) Viewed 2059 times
SDCard pipe directory.PNG
SDCard pipe directory.PNG (4.87 KiB) Viewed 2059 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!

Re: Import micropython-lib

Posted: Tue Dec 12, 2017 7:34 pm
by iabdalkader
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 2053 times

Re: Import micropython-lib

Posted: Tue Dec 12, 2017 7:42 pm
by mannybranden7
Oh okay I see. I am sorry I didn't make that connection before.

Thank you for such a quick reply.

Re: Import micropython-lib

Posted: Tue Dec 12, 2017 8:29 pm
by kwagyeman
Oh, yeah, alot of the MPlib stuff is for the unix port of MicroPython.