按照RT-THREAD官方的移植,在自己的板子上运行python。micropython可以运行py文件了,文件名是test.py,但是通过mpy-cross将py文件编译成mpy文件后,在命令行界面import test正常,下一步执行test.ttt(),会报错name not defined。请问各位这是哪里导致的,工程代码需要改哪个地方?谢谢文件内容是一个简单的打印:
def ttt():
print("12345")
micropython运行mpy文件问题
Re: micropython运行mpy文件问题
是的,只是运行py文件的话是完全正常的。编译成mpy文件后(test.mpy),执行import test也正常,然后我在命令行界面输入test.t然后按Tab键,能够自动补齐test.ttt,所以感觉解释器已经把npy文件解析出来了。但是我继续执行test.ttt()就会报错
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 2, in ttt
NameError: name not defined
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 2, in ttt
NameError: name not defined
- shaoziyang
- 帖子: 3994
- 注册时间: 2019年 10月 21日 13:48
Re: micropython运行mpy文件问题
先看看micropython版本是不是最新版本,可以在其它板子上也试试,确定一下是mpy-cross问题,rtt移植的问题,还是micropython的bug。
Re: micropython运行mpy文件问题
可能是UTF-8的问题
mpy-cross-amd64.exe -mno-unicode text.py
mpy-cross-amd64.exe -mno-unicode text.py
Re: micropython运行mpy文件问题
我有个nucleo-h743zi的板子,我想编译一下micropython官方的移植试一下的,现在板子可以正常跑,想问一下您,怎么把mpy文件下载到板子里面
-
- 随机主题
- 回复总数
- 阅读次数
- 最新文章
-
- 3回复总数
- 4444 阅读次数
- 最新文章 由 zwjiang
2020年 3月 29日 14:33
-
- 2回复总数
- 5746 阅读次数
- 最新文章 由 shaoziyang
2020年 3月 29日 11:00
-
- 3回复总数
- 4892 阅读次数
- 最新文章 由 slotg
2020年 3月 30日 18:31