Hi, working with Thonny I tried many times to flash a main.py into a couple different 8266 working fine until now. I tried files uploading in different sequential order (I’ve 5 files which must be on the 8266) and after flashing my main.py and reset I get this error:
“Traceback (most recent call last):
File “B:\Programming\uPython\Thonny\lib\site-packages\thonny\workbench.py”, line 1598, in event_generate
handler(event)
File “B:\Programming\uPython\Thonny\lib\site-packages\thonny\base_file_browser.py”, line 872, in update_dir_data
self.cache_dirs_child_data(msg[“data”])
File “B:\Programming\uPython\Thonny\lib\site-packages\thonny\base_file_browser.py”, line 315, in cache_dirs_child_data
for parent_path in data:
TypeError: ‘NoneType’ object is not iterable”
After closing the message window most of times I’m not able to upload files anymore: if I try it stays in “saving” message forever and I must close by its “cancel” button. Resetting the board I get a list of objects like this one:
“<thonny>{‘/’: {‘boot.py’: {‘size’: 230, ‘kind’: ‘file’, ‘time’: 946684800}, ‘main.py’: {‘size’: 8062, ‘kind’: ‘file’, ‘time’: 946684800}, ‘pyramid_lib.py’: {‘size’: 1285, ‘kind’: ‘file’, ‘time’: 946684800}}}</thonny>>”.
Sometimes I can upload another file but then I get stuck as I told before. In some cases trying on and on I can go on but it’s a nightmare to develop software this way!
I flashed a fresh micropython a couple times (esp8266-1m-20200421-v1.12-388-g388d419ba.bin) and restarted the process but everytime the story repeats.
Please can anyone help?
Hi Enzo.
That seems to be a problem with the IDE.
Which version of Thonny are you using?
Also, are you sure you have enough space on the ESP8266 for all files?
Regards,
Sara
Hi Sara,
Thonny version is 3.2.7.
In total now are less than 300 rows of code (including comments): 8266 has 1MB of flash, right? There should be plenty of space for many more lines I have to code.
Btw, is there any way to try code without actually flashing it to board to avoid wearing out the flash? I coded and debugged all what I can in Spyder but many features are intrinsic to 8266 (i. e. RTC and others) and micropython doesn’t implement all python language. Any good emulator out there?
Hi Enzo.
With MicroPython, you can simply run the code before uploading it to your board.
In Thonny IDE, there’s a green “play” button that runs the code on your board. This doesn’t upload the code, it just runs it, and you can see if it’s working as expected.
If everything is working fine, you can proceed and upload the files.
That’s also the version of Thonny I’m using, and it’s been working well.
What does your code do?
Regards,
Sara
Hi Sara,
thr boot connects to wifi as a station; the main imports .cfg file with an empty dictionary and some functions from another file to initialize the environment (RTC, ntptime, create a couple dirs if not existing) and then checks for files in one of these dirs (/new): if present it creates an object with a couple properties and three empty dictionaries. Other lines are commented now.
Nice regards.
Enzo
Hi Enzo.
That doesn’t seems overly complicated to cause errors.
I noticed now that you’re not using the Stable firmware version of MicroPython. You’re using the daily builds.
I recommend using the Stable firmware.
See it here: https://micropython.org/download/esp8266/
Additionally, if you want to experiment with other IDEs, you can try PyCharm with the MicroPython Plugin:https://blog.jetbrains.com/pycharm/2018/01/micropython-plugin-for-pycharm/ (I haven’t tried it, but it seems to work fine).
Regards,
Sara
Hi Sara,
now it seems to run more smoothly. Thanks, I didn’ notice the one I downloaded was a daily release!
You told that “run” in Thonny doesn’t actually runs in the board but does it emulates the peripherals, too? I mean RTC for instance.
Best regards,
Enzo
When you hit “run”, it runs the code, but doesn’t upload it to the board.
However, the peripherals behave as expected, sensor readings, controlling outputs and using other modules. So, the RTC should also work.
When you’re happy with your code, don’t forget to upload it to your board to have it permanently saved.
I hope this is clear.
Regards,
Sara
Hi Sara,
things go better than before but I see strange behaviour every here and there.
E.g. after some changing to a couple lines of code it creates a file in the board but doesn’t create the same file when running in Thonny.
Other case: reset the board once, run the main and it issues an error of a file missing, reset again and all goes ok!
And in some cases when I reset returns the error ““Traceback (most recent call last):
File “B:\Programming\uPython\Thonny\lib\site-packages\thonny\workbench.py”, line 1598, in event_generate
handler(event)
File “B:\Programming\uPython\Thonny\lib\site-packages\thonny\base_file_browser.py”, line 872, in update_dir_data
self.cache_dirs_child_data(msg[“data”])
File “B:\Programming\uPython\Thonny\lib\site-packages\thonny\base_file_browser.py”, line 315, in cache_dirs_child_data
for parent_path in data:
TypeError: ‘NoneType’ object is not iterable”.
Maybe micropython is not so stable? Or maybe I’m doing something wrong?
Have a nice day!
Enzo
Hi Enzo.
I’ve never had those kind of problems with MicroPython.
The IDEs might be a bit tricky to work with. Mainly when running and saving files. One of the oldest versions of Thonny worked better handling the files. Unfortunately, I also updated my Thonny IDE to the latest version and I don’t know what was the previous version I had.
What’s the error of the missing file? Is it a file that it should have loaded and doesn’t find it?
The last error, I have no idea what it means :\
Regards,
Sara
Hi Sara,
- Missing file: I write a file by code (saving some strings), it seems ok, no errors, but when I look for it in the board files dir of the IDE it isn’t there. The same when creating directories. This doesn’t happen all the times: sometimes all is ok and this without any changes in that part of code. Maybe I unplug the board and, leaving it unplugged for more time, when it’s plugged in again that file is there!
- Importing my libraries:
from pyramid_lib import makeDirs, createHomePlugs,checkRTC, checkFlashID from pyramid_lib import writeHomePlugs
These 2 lines import functions from my same library, the functions in the library have the correct syntax (I tried it in Spyder and they are ALL correctly imported) but Thonny and the board raise an error for the second line: "ImportError: cannot import name writeHomePlugs". I couldn't explain why!
Moreover if I run the main again it does nothing but Thonny issues:
“<thonny>{‘esp’: “<module ‘esp’>”, ‘ext’: “‘.csv'”, ‘ntptime’: “<module ‘ntptime’>”,
‘writeHomePlugs’: ‘<function writeHomePlugs at 0x3fff0190>’, ‘makeDirs’:
‘<function makeDirs at 0x3fff0220>’, ‘connect_to_wifi’: ‘<function connect_to_wifi at 0x3fff01a0>’,
‘checkFlashID’: ‘<function checkFlashID at 0x3fff0230>’, ‘os’: “<module ‘uos’>”, ‘createHomePlugs’:
‘<function createHomePlugs at 0x3fff0180>’, ‘checkRTC’: ‘<function checkRTC at 0x3fff01b0>’,
‘RTC’: “<class ‘RTC’>”, ‘root_dir’: “‘/'”, ‘network’: “<module ‘network’>”}</thonny>>and the only way to go on is to restart the backend.
I just tried it and all has been ok (no editing to code): the import is ok and all works as expected!!!
It’s a nightmare to develop anything in such way! If only i could understand
WHERE is the problem maybe we could try to solve it.
Please, help 🙂
Nice regards,
Enzo
Update: now I’m trying to understand what’s the exact sequence of write to pc/board, reset, restart the backend.
It seems (?) that if you don’t save the code to the board, as well as to the pc, the execution from the pc stays with the previous code (before the new saved one).
It worked ok for a couple times: resetting the board the new code was executed. Reset for the 3rd time: the error of the previous code comes back as if the previous version of file had been restored (of course I had not!). And Thonny didn’t run the code anymore: I had to close Thonny and restart it. Now the code runs ok.
I guess there must be some issue with Thonny: it seems as if it sometimes confuses what code to execute/save on the pc/board and, quite often, needs to be restarted to get back to the right behaviour.
Hi Enzo.
That’s a very weird behavior. I usually don’t have such issues with Thonny IDE.
Maybe you considering trying another IDE. I think VSCode supports micropython now (although I haven’t found much information about it), or trying PyCharm.
I haven’t experimented with these IDEs myself, it’s just a suggestion.
Regards,
Sara
Hi Sara,
a quick update just in case it can be useful for anyone: the “strange” errors I found in Thonny are known bugs.
I searched through Thonny Github and there are other issues open on the same topic. They told will try to fix in a next update.
Nice regards.
Enzo