Can`t run a programm

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
nesergen
Posts: 23
Joined: Mon Oct 26, 2020 9:17 pm

Can`t run a programm

Post by nesergen » Mon Jul 11, 2022 11:06 am

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?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Can`t run a programm

Post by jimmo » Mon Jul 11, 2022 11:48 am

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?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Can`t run a programm

Post by jimmo » 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.

nesergen
Posts: 23
Joined: Mon Oct 26, 2020 9:17 pm

Re: Can`t run a programm

Post by nesergen » Mon Jul 11, 2022 2:45 pm

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Can`t run a programm

Post by jimmo » Mon Jul 11, 2022 2:50 pm

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.

Post Reply