General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm


Post by johnv » Mon Dec 23, 2019 2:00 pm


i want to run a script directly from booting the device,

when i make a file it runs it straight from boot,

but when i make a folder with my file as a subdirectory it doesnt,

can you run subdirectories in or can you only run it as a single file?

Posts: 34
Joined: Mon Jan 26, 2015 2:05 pm

Re: booting

Post by MCHobby » Mon Dec 23, 2019 2:33 pm

You can place all your files in the root directory of the board file system.
You can also place your library into the "lib" subfolder.
A third option is to create a sub-directory say "mydir" and then, you can append the "mydir" entry into the sys.path list.
Place your starting code inside a file named "" inside the "mydir" folder. From "" you wil be able to write "import" and your software will be imported from "mydir" (as available in the sys.path) and executed.

PS: I don't know if sys.path can be modified directly from but it should be possible.


Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm

Re: booting

Post by johnv » Mon Dec 23, 2019 8:54 pm

this is the code from the folder

Code: Select all

import sys
print (sys.path.insert)
from mydir import mymain
so i went for the third option,

i must say it took a while but i learned alot in my search :D

i created a folder named 'mydir'

and put 2 files in it: '' and ''

the last one so it would recognize the 'mydir' folder as a module.

tnx dominique, youre awesome!!!

btw is this the best way to implement it? i just put some code togheter from different sites and tried to make something work :)

User avatar
Posts: 4242
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: booting

Post by pythoncoder » Tue Dec 24, 2019 7:27 am

You might also want to look up "Python packages" in any tutorial to learn more about using subdirectories to contain Python code.
Peter Hinch

Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm

Re: booting

Post by johnv » Tue Dec 24, 2019 7:56 am

i will look into it, tnx for the info! ;

i ordered this book, i hope it wil be any good :D Advanced Programming in MicroPython By Example by magda yuri

and a small bookbinding machine, so i can print out stuff from the internet and keep it tighty :lol:

Posts: 2
Joined: Sat Dec 07, 2019 8:50 pm

Re: booting

Post by hydraspl » Tue Dec 24, 2019 2:15 pm

Can I fix this on my own or should I know the basics of programming?

The best way to choose the best lender service? Always compare the proposals of the different banks with each other! Only in this way can you find the cheapest deal in your state, with your level of income, and for the time period that feels comfortable for you. Many here stress the improtance of finding the best rate, but there are situations when you cannot really choose and honestly, many people looking for a payday loan are in no position to choose. Some of them have low income to show for themselves, others have bad credit history, we all have financial problems from time to time. My advice is, do look around, visit a couple of websites with the rates compared, but do not forget that it is but a short term loan. Take it out, use it, and focus on improving your budget planning to never need a loan again. Good luck!

Post Reply