Page 1 of 1

Having Trouble Getting PyCharm to work

Posted: Wed Feb 12, 2020 7:02 am
by lc2047
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

Re: Having Trouble Getting PyCharm to work

Posted: Fri Feb 14, 2020 4:00 am
by jimmo
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?)

Re: Having Trouble Getting PyCharm to work

Posted: Sun Feb 16, 2020 10:43 am
by lc2047
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

Re: Having Trouble Getting PyCharm to work

Posted: Sun Feb 16, 2020 7:27 pm
by Roberthh
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.

Re: Having Trouble Getting PyCharm to work

Posted: Thu May 07, 2020 2:13 am
by lc2047
Hi @Roberthh

Thanks for your comment.
Is there any micropthon IDE for BOTH microbit & pyboard?

Do pyboard necessary with SD card for a program? There are 88.5kB only of "PYBFLASH" driver. With microbit, there have ~64MB free.

Or the program file(s) need a special method(not copy-&-paste) to transfer to pyboard. If yes, please let me know, how to do it.


BR

LC

Re: Having Trouble Getting PyCharm to work

Posted: Thu May 07, 2020 9:31 am
by Jurjen
lc2047 wrote:
Thu May 07, 2020 2:13 am
Hi @Roberthh

Thanks for your comment.
Is there any micropthon IDE for BOTH microbit & pyboard?

...

BR

LC
Yes, I use Thonny, it supports them both (I have PybD and ESP8266):
  • PyBoard (including the newer PybD) are supported by the generic MicroPython interpreter
  • MicroBit can be selected as a specific interpreter
  • Some other devices (ESP8266, ESP32, CircuitPython) are supported with selectable interpreters as well
I have the impression that Thonny is the only IDE supporting various hardware platforms that is currently being actively maintained. It is simple but does the job for me. I tried PyCharm with the MicroPython plugin but the latter has issues and is not maintained anymore anyways, so I decided to get rid of it. You might opt to develop your generic IDE code in a proper IDE like PyCharm and then in the end tune it towards micropython-specific items using Thonny.
There are some posts on this forum as well on internet in general on the PyCharm + microPython combination.

/Jurjen