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?
[SOLVED] Error when import compiled mpy bytecode
-
- Posts: 81
- Joined: Fri Sep 02, 2016 9:26 am
[SOLVED] Error when import compiled mpy bytecode
Last edited by ajie_dirgantara on Tue Sep 19, 2017 10:41 am, edited 1 time in total.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Error when import compiled mpy bytecode
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.
Index to my micropython libraries.
-
- Posts: 81
- Joined: Fri Sep 02, 2016 9:26 am
Re: Error when import compiled mpy bytecode
Ok, actually I am using the latest release (version 1.9.2) and did not do any changes...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.
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?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Error when import compiled mpy bytecode
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.
Index to my micropython libraries.
-
- Posts: 81
- Joined: Fri Sep 02, 2016 9:26 am
Re: Error when import compiled mpy bytecode
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
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Error when import compiled mpy bytecode
I cross compiled that, copied it to a Pyboard V1.1 and imported it without error.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 81
- Joined: Fri Sep 02, 2016 9:26 am
Re: Error when import compiled mpy bytecode
ok, I found the problem.pythoncoder wrote:I cross compiled that, copied it to a Pyboard V1.1 and imported it without error.
need this line listed on mpconfigport.h when compile :
Code: Select all
#define MICROPY_ENABLE_COMPILER (1)