Page 1 of 1

Can`t run a programm

Posted: Mon Jul 11, 2022 11:06 am
by nesergen
Good day!

I`m trying to start the program using function

Code: Select all

pyb.main(bootFileName)
in the boot.py . But I get an error:

Code: Select all

13:50:57.924 -> Traceback (most recent call last):
13:50:57.924 ->   File "main_v16.mpy", line 1
13:50:57.924 -> SyntaxError: invalid syntax
It is strange because if I use

Code: Select all

import bootFileName 
the file starts normally.

What may be the reason of such behavior?

Re: Can`t run a programm

Posted: Mon Jul 11, 2022 11:48 am
by jimmo
nesergen wrote:
Mon Jul 11, 2022 11:06 am
I`m trying to start the program using function

pyb.main(bootFileName)
This should be

Code: Select all

pyb.main("bootFileName.py")
But there's more going on because you're also using .mpy files (i.e. via the cross compiler)? Can you provide more information?

Re: Can`t run a programm

Posted: Mon Jul 11, 2022 11:52 am
by jimmo
Ohh... wait... are you trying to use a cross-compiled main_v16.mpy as your main.py? I think pyb.main has to be a .py file. You can only load .mpy via import.

Re: Can`t run a programm

Posted: Mon Jul 11, 2022 2:45 pm
by nesergen
jimmo wrote:
Mon Jul 11, 2022 11:52 am
Ohh... wait... are you trying to use a cross-compiled main_v16.mpy as your main.py? I think pyb.main has to be a .py file. You can only load .mpy via import.
You are right. I`m trying to start .mpy file. It`s not clear in docs that pyb.main() can only starts .py files.

Re: Can`t run a programm

Posted: Mon Jul 11, 2022 2:50 pm
by jimmo
nesergen wrote:
Mon Jul 11, 2022 2:45 pm
It`s not clear in docs that pyb.main() can only starts .py files.
I have just fixed this in a pending docs PR i'm working on.