Page 1 of 1

Newbie question - PIP?

Posted: Thu Mar 16, 2017 10:35 am
by Miffo
Hi,

I'm a newbie to python and a newbie to micropython so I don't even know the proper terms to ask the question!

I've got a small python application that is running on a Windows PC. I want to see if micropython will run the application on our embedded system. To do that, I thought I'd run micropython on a Windows PC first (as we've not got micropython available yet on the embedded system). I've compiled up the source and can run a hello world program.

When I run the application, it fails on "import parseargs". How do I go about installing modules? Every time I try and find the answer, it's mainly about how to get it installed on "boards" (or something). I'm sure I got further with this a few months ago but can't seem to find the pages I found before so I know it's a pretty stupid question but I'm stuck!

I think we use PIP with the normal python for this sort of thing.

Thanks.

Peter.

Re: Newbie question - PIP?

Posted: Fri Mar 17, 2017 7:10 am
by pythoncoder
I suggest you read https://github.com/micropython/micropyt ... ifferences.

tl;dr MicroPython is primarily designed to run on microcontrollers. These are resource constrained. Consequently many of the standard Python libraries are not supported. In some cases 'micro' versions of standard libraries are offered.

Re: Newbie question - PIP?

Posted: Fri Mar 17, 2017 3:00 pm
by Miffo
Hi,

Thanks for the reply. I read most of that page. I could be OK. It all depends on library support. I found a link that page to this one -

https://github.com/micropython/micropython-lib

The first library I was looking for is listed there (argparse) so I downloaded that and put the "argparse" folder in the same folder as my script and it now doesn't complain about the import. So that's great.

Is there another place that I can put it though? I don't really like it mixed up with my own code.

Thanks.

Peter.

Re: Newbie question - PIP?

Posted: Fri Mar 17, 2017 4:20 pm
by dhylands
You can control the location using sys.path

By default, sys.path has /flash, /flash/lib, /sd, /sd/lib (the /sd paths only exist if an sd card is inserted). You can append to that or otherwise modify it as you see fit.