Having Trouble Getting PyCharm to work

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lc2047
Posts: 2
Joined: Wed Jul 25, 2018 4:23 am

Having Trouble Getting PyCharm to work

Post by lc2047 » Wed Feb 12, 2020 7:02 am

Hi

I tried to use pycharm for micropython(ESP8266) and follow "https://blog.jetbrains.com/pycharm/2018 ... r-pycharm/" to config pycharm & install micropython plug-in.
After that pycharm detected my ESP8266, but having a problem while trial demo program(show below)

Code: Select all

import utime
from machine import Pin


def main():
    led = Pin(2, Pin.OUT)
    enabled = False
    while True:
        if enabled:
            led.off()
        else:
            led.on()
        utime.sleep_ms(1000)
        enabled = not enabled


if __name__ == '__main__':
    main()
The problem is no module named 'utime' & 'machine'. Do they ready include in MicroPython(enable support ready) plug-in? Is it necessary to enable?

Please share your comments.

BR

User avatar
jimmo
Posts: 1156
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Having Trouble Getting PyCharm to work

Post by jimmo » Fri Feb 14, 2020 4:00 am

utime and machine are definitely available on the ESP8266 port.

Is it possible that it's trying to run your code in regular Python (i.e. CPython) rather than on the device? (i.e. the plugin isn't actually being used?)

lc2047
Posts: 2
Joined: Wed Jul 25, 2018 4:23 am

Re: Having Trouble Getting PyCharm to work

Post by lc2047 » Sun Feb 16, 2020 10:43 am

Hi Jimmo

Thanks for your comment.
I tried to run it in PyCharm(PC). I think the code needs running(like to comply) first, then download to ESP8266.
My problem seem that it is not a success to comply.

With PC version python env., utime seen is included in "os". How about "machine"? Without it, what should be expected in the trial run?

BR

User avatar
Roberthh
Posts: 1837
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Having Trouble Getting PyCharm to work

Post by Roberthh » Sun Feb 16, 2020 7:27 pm

You cannot run the ESP8266 code on the PC. The specific hardware is not present on a PC, and therefore the python modules do not exist.

Post Reply