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: 5
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: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

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: 5
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: 3667
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.

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

Re: Having Trouble Getting PyCharm to work

Post by lc2047 » Thu May 07, 2020 2:13 am

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

Jurjen
Posts: 5
Joined: Sun Apr 19, 2020 10:54 am

Re: Having Trouble Getting PyCharm to work

Post by Jurjen » Thu May 07, 2020 9:31 am

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

Post Reply