[SOLVED] Error when import compiled mpy bytecode

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

[SOLVED] Error when import compiled mpy bytecode

Post by ajie_dirgantara » Wed Sep 13, 2017 8:14 am

This is the first time I've use mpy-cross
and I've got this error when import the module :

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid syntax for number



any thoughts?
Last edited by ajie_dirgantara on Tue Sep 19, 2017 10:41 am, edited 1 time in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Error when import compiled mpy bytecode

Post by pythoncoder » Wed Sep 13, 2017 8:19 am

Most of these issues result from using an out-of-date cross compiler. Each time you pull from the repository it's wise to rebuild the cross compiler.
Peter Hinch
Index to my micropython libraries.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Error when import compiled mpy bytecode

Post by ajie_dirgantara » Tue Sep 19, 2017 6:54 am

pythoncoder wrote:Most of these issues result from using an out-of-date cross compiler. Each time you pull from the repository it's wise to rebuild the cross compiler.
Ok, actually I am using the latest release (version 1.9.2) and did not do any changes...

if I am putting my .py in /modules to compiled into frozen byte code, it is works fine, but why can't I compile and use it externally just like .py files?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Error when import compiled mpy bytecode

Post by pythoncoder » Tue Sep 19, 2017 9:43 am

Is it possible you have a (faulty) file with the same name but a .py extension? Otherwise I think you'll have to post a code sample that fails. The cross compiler works fine here.
Peter Hinch
Index to my micropython libraries.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Error when import compiled mpy bytecode

Post by ajie_dirgantara » Tue Sep 19, 2017 9:48 am

pythoncoder wrote:Is it possible you have a (faulty) file with the same name but a .py extension? Otherwise I think you'll have to post a code sample that fails. The cross compiler works fine here.

Ok, I attached the code. it is a pure python aes CBC/EBC implementation. it works as a script, but not as a compiled bytecode though.
Attachments
aes_bytecode.zip
the result .mpy file
(3.54 KiB) Downloaded 265 times
aes.zip
the .py file
(2.78 KiB) Downloaded 245 times

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Error when import compiled mpy bytecode

Post by pythoncoder » Tue Sep 19, 2017 10:11 am

I cross compiled that, copied it to a Pyboard V1.1 and imported it without error.
Peter Hinch
Index to my micropython libraries.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Error when import compiled mpy bytecode

Post by ajie_dirgantara » Tue Sep 19, 2017 10:40 am

pythoncoder wrote:I cross compiled that, copied it to a Pyboard V1.1 and imported it without error.
ok, I found the problem.

need this line listed on mpconfigport.h when compile :

Code: Select all

#define MICROPY_ENABLE_COMPILER     (1)
wonder why it isn't enabled by default.

Post Reply