Code editor

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ajocius
Posts: 83
Joined: Mon Feb 19, 2018 6:31 am

Code editor

Post by ajocius » Thu Mar 29, 2018 7:27 pm

Please recommend editor to work with Micropython. I struggle to see where I make mistake, some invisible characters stops all they joy...

Last half an hour I am trying to align code but it throws me errors. As soon as I fix one line (by deleting space at the beginning of line and then tabbing text to the right place), I get error in another line... So I deal with errors like this:
"IndentationError: unexpected indent
MicroPython v1.9.3-318-g60c6b880 on 2018-02-17; ESP32 module with ESP32
"
"IndentationError: unindent does not match any outer indentation level
"

i hope with "right" editor I could possibly see lines with incorrect syntax?

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: Code editor

Post by ARTaylor » Thu Mar 29, 2018 8:50 pm

If you post your code we can probably help you

I use Atom Text Editor with Hydrogen and the Platform IO Terminal Packages - works great for me

EDIT: rshell for your terminal session is pretty useful as well
Grow something!

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: Code editor

Post by Capstan » Fri Mar 30, 2018 12:50 am

I use Microsoft Visual Studio Code (VSCode for short). It is a free download and runs on many platforms. You can install a variety of extensions in it that do all kinds of useful things. One of them is pylint, which identifies many kinds of syntax and indentation errors plus calling methods with the wrong arguments.

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

Re: Code editor

Post by pythoncoder » Fri Mar 30, 2018 4:25 am

@ajocius It would help if you told us what OS you're using. For Linux I recommend Kate.

In Python whitespace matters. Best practice is to configure your editor to convert tabs to spaces (usually four). A mixture of tabs and spaces is a recipe for total confusion where code looks correct but will typically be rejected by the compiler. I suspect this may be your problem.

For communicating with the target I recommend rshell. This is written in Python, runs on Windows/Linux/OSX.
Peter Hinch
Index to my micropython libraries.

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Code editor

Post by stijn » Fri Mar 30, 2018 6:20 am

Capstan wrote:
Fri Mar 30, 2018 12:50 am
One of them is pylint
This. Any proper text editor which supports live linting + automatic formatting plugins (pep8/flake8/pylint) will save you a ton of time.

ajocius
Posts: 83
Joined: Mon Feb 19, 2018 6:31 am

Re: Code editor

Post by ajocius » Fri Mar 30, 2018 8:40 am

Thanx, will test it out.

My bad, did not state OS I use. I use Windows 10 x64 (have another pc with W10 x32).

I have Raspberry Pi3 with Raspbian , so I connect with Putty from Windows. Then ESP32 is connected to Rpi3 via usb cable. I run command "rshell --buffer-size=30 -p /dev/ttyUSB0 " to connect to ESP32 and run "repl" there to get feedback from micropython code running on ESP32. I have tested most of code directly in repl, by copying and pasting command lines, so it must be some space/tab issue there. Hopefully listed code editors will help to highlight that. I have been using notepad++ so far.

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: Code editor

Post by ARTaylor » Fri Mar 30, 2018 8:46 am

ajocius wrote:
Fri Mar 30, 2018 8:40 am
Thanx, will test it out.

My bad, did not state OS I use. I use Windows 10 x64 (have another pc with W10 x32).

I have Raspberry Pi3 with Raspbian , so I connect with Putty from Windows. Then ESP32 is connected to Rpi3 via usb cable. I run command "rshell --buffer-size=30 -p /dev/ttyUSB0 " to connect to ESP32 and run "repl" there to get feedback from micropython code running on ESP32. I have tested most of code directly in repl, by copying and pasting command lines, so it must be some space/tab issue there. Hopefully listed code editors will help to highlight that. I have been using notepad++ so far.
I like to use vim for Python (and lots of other stuff) on the Raspberry Pi - but then I am a freak :lol:
Grow something!

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Code editor

Post by kevinkk525 » Fri Mar 30, 2018 10:31 am

I am using Eclipse with pydev plugin for development.
I am using Windows (mainly, at least on my main pc).
To connect to the ESP I made myself some scripts that I run as external tools that sync my files, build the firmware, flash the firmware and connect using rshell/mpfshell. These tools are made for linux which I run in WSL Ubuntu.
My µC are directly connected to my PC.

This worked best for me by now and even using the tools is just a few clicks. of course the micropython specific packages are not included in my development environment but at least the standard python are and I have a folder with all external modules like uasyncio that I include in the pythonpath of my project so I get autocompletion for these as well.

If you know a better way, let me know :D
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

ajocius
Posts: 83
Joined: Mon Feb 19, 2018 6:31 am

Re: Code editor

Post by ajocius » Wed Apr 11, 2018 7:57 am

I tried Atom code editor, suggested by #ARTaylor . Works great, has various plug ins available, checks syntax, etc. Exactly what i was looking for, thank you!

Post Reply