Page 1 of 1

Micropython Language for VS Code

Posted: Wed May 08, 2019 7:47 am
by Jerremy09
Hello all,

I would like to ask if there is some posibility to add directly "Micropython" language into VS Code with linghter? Currently I use Python with Pylint, but it would be nice to have directly Micropython insiide.

Thank you

Jan

Re: Micropython Language for VS Code

Posted: Wed May 08, 2019 7:50 am
by torwag
It depends on what you want to achieve.

Just syntax or do you want to have a way to run the code directly on a connected uC?

You might want to look into platformio, which works together with VS code and afaik they work on micropython support. There is a plugin already.

Re: Micropython Language for VS Code

Posted: Fri Jun 14, 2019 11:29 am
by klindber
There is one extension on VS Code calle PyMakr, it is focused on Pycom boards but it seemed to work for many people who wanted to run MicroPython on VSCode.

For me personally it didn't work. After installation it always prompt an error message about serialport module one time and another (I think it was some problem with my NodeJS version), so I changed to uPycraft which is working very well but it does not have Intellisense. :roll:
***
torwag wrote:
Wed May 08, 2019 7:50 am
It depends on what you want to achieve.

Just syntax or do you want to have a way to run the code directly on a connected uC?

You might want to look into platformio, which works together with VS code and afaik they work on micropython support. There is a plugin already.
Oh I didn't know about this, PlatformIO is great, I will see if I can get it to work with MicroPython. Thanks for the info!

Re: Micropython Language for VS Code

Posted: Tue Jun 18, 2019 2:37 pm
by zouden
Hi Jerremy,

For language support I use this: https://github.com/Josverl/micropython-stubber
Follow the instructions there and you'll get *most* of the micropython modules supported by pylint. It doesn't pick up 3rd party modules though. But it's better than nothing!

Also, I wrote an extension called Micropython REPLink. It lets you send code to the REPL and/or save it as a file. I wrote it because I wasn't happy with any of the other extensions like pymakr. It relies on you to provide a REPL shell, and for that I use mpfshell. Hope you find it useful :)

Re: Micropython Language for VS Code

Posted: Fri Jul 26, 2019 2:17 am
by BradenM
Hi,

continuing on what @zouden said, you may be interested in my project: https://github.com/BradenM/micropy-cli

It uses micropython-stubber, what zouden had linked above, but also solves the issue of 3rd party modules with its dependency management system. Basically, you can install modules to your project with Micropy and it will automatically stub them, allowing you to import them as you would on your device and have autocompletion/intellisense like the included modules.

Re: Micropython Language for VS Code

Posted: Tue Jan 21, 2020 5:44 pm
by Jerremy09
Hi klindber,

I use "PyMakr" and I can say that Im very sattisfied with it. It works greate if you want to upload whole project to board (currently I have 62 files and it is uploaded with one click). I use "Lolin D32 Pro V2" and PYMAKR do not have any issues to find it.

here is my details of VS Code I use:
Version: 1.41.1 (user setup)
Commit: 26076a4de974ead31f97692a0d32f90d735645c0
Date: 2019-12-18T14:58:56.166Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.16299

I also neede to update "Pymakr Global Setup":
{
"address": "COM7",
"username": "",
"password": "",
"sync_folder": "",
"open_on_start": true,
"safe_boot_on_upload": false,
"fast_upload": true,
"sync_file_types": "py,log,json,xml,html,js,css,mpy,bin",
"ctrl_c_on_connect": true,
"sync_all_file_types": false,
"auto_connect": false,
"py_ignore": [],
"autoconnect_comport_manufacturers": [
"Pycom",
"Pycom Ltd.",
"FTDI",
"Microsoft",
"Microchip Technology, Inc."
]
}
klindber wrote:
Fri Jun 14, 2019 11:29 am
There is one extension on VS Code calle PyMakr, it is focused on Pycom boards but it seemed to work for many people who wanted to run MicroPython on VSCode.

For me personally it didn't work. After installation it always prompt an error message about serialport module one time and another (I think it was some problem with my NodeJS version), so I changed to uPycraft which is working very well but it does not have Intellisense. :roll:
***
torwag wrote:
Wed May 08, 2019 7:50 am
It depends on what you want to achieve.

Just syntax or do you want to have a way to run the code directly on a connected uC?

You might want to look into platformio, which works together with VS code and afaik they work on micropython support. There is a plugin already.
Oh I didn't know about this, PlatformIO is great, I will see if I can get it to work with MicroPython. Thanks for the info!

Re: Micropython Language for VS Code

Posted: Tue Jan 21, 2020 6:06 pm
by Jerremy09
Hi all,

thank you for your post, I will try the "Josverl" and "Braden" ways. Main point was to get to VSCode something which is not going to lint code like "import machine" ... (so micropython internals at all). I do understand to the fact that locally created function stored in another .py file can/cannot be counted and will or not will be linted, but this is good.

so thank you

Jan

Re: Micropython Language for VS Code

Posted: Fri Oct 30, 2020 10:36 am
by RDA
Hello,

I have been using ESP boards with arduino IDE and now Im trying out micropython. I have tried to setup an ESP32 to work in VS Code (win10) but I have ran into issues with linting.

I am unable to example import 'machine'. "import machine" results in
"Unable to import 'machine' pylint(import-error) [1, 1]

I can import example time wihout errors, I can also of course "import machine" using putty or pymakr terminal. Pymakr and esptool both "work", I am just struggling probably on setting up the environment (virtual) somehow (python 3.8.1 64-bit ('.venv').

Any help on this is much appreciated

EDIT:
I dont know what I was thinking as the machine is a device specific thing... I still cant get it to run by uploading the code but I will make another thread on that.

EDIT2:
I am a dumb ass, it works, I was thinking pymakr upload would autorun and did not actually run the code...