'Setting up Raspberry Pi Pico (No module named 'Machine')

I'm trying to set up a raspberry pi pico for the first time. I've got micropython installed, and got my environment set up in Pycharm. I wrote a simple program to test my setup, and I'm getting this error:

Traceback (most recent call last):
File "D:\...\Blink.py", line 1, in <module>
    from machine import Pin
ModuleNotFoundError: No module named 'machine'

Here's the code:

from machine import Pin
import time

led = Pin(25, Pin.OUT)
while True:
    led(1)
    time.sleep(1)
    led(0)
    time.sleep(1)

I've found other questions where people had a similar problem when using an ESP32, but I'm wondering how to handle this in pycharm with a pi pico



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source