Visual Studio Code not recognizing CircuitPython librarys

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
LukeR
 
Posts: 14
Joined: Sun May 15, 2022 2:56 pm

Visual Studio Code not recognizing CircuitPython librarys

Post by LukeR »

I am trying to program a Feather M4 Express with an Ethernet Featherwing using Visual Studio Code. I am not sure if I don't have something, not set up correctly, but if I write something as simple as "import board", VS code gives the following error:
Untitled.png
Untitled.png (3.43 KiB) Viewed 160 times

I don't know if the problem is in the way that I have VS code setup or not.

I have these extensions installed:
extentions.png
extentions.png (52.43 KiB) Viewed 160 times
If I write the simple blink program, it will run it, but VS code still does not like it.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Visual Studio Code not recognizing CircuitPython library

Post by mikeysklar »

I've not tried VScode myself, but it sounds as though you might have missed some of the necessary extension setup for the workspace or command run?

https://marketplace.visualstudio.com/it ... cuitpython

This links get into more details about the setup:

https://www.hanselman.com/blog/using-vi ... trellis-m4

User avatar
LukeR
 
Posts: 14
Joined: Sun May 15, 2022 2:56 pm

Re: Visual Studio Code not recognizing CircuitPython library

Post by LukeR »

I didn't see anything that I missed. the board library is the only one that I have found that does not work.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Visual Studio Code not recognizing CircuitPython library

Post by adafruit2 »

you can run
import os
os.uname()
at the repl, to see what python you're running from

User avatar
neradoc
 
Posts: 542
Joined: Wed Apr 27, 2016 2:38 pm

Re: Visual Studio Code not recognizing CircuitPython library

Post by neradoc »

It looks indeed like you are running the code on the host PC, as shown by the "F:" path to the file.
This would happen if you click the green triangle at the top of the window. Is that what you did ?
I get the same message as you when I do that:
vsc-python-run.jpg
vsc-python-run.jpg (66.98 KiB) Viewed 124 times
In Circuitpython you don't run the code like this, code.py runs automatically on start and reruns when you save (or do ctrl-C/ctrl-D in the serial console).
To see the output of your code, you connect to the board's serial console by selecting a COM port with the button at the bottom of the screen (when the extension is active).
You can also use an external app for serial connection like Tera Term
Capture-vsc.PNG
Capture-vsc.PNG (11.21 KiB) Viewed 124 times
Leading to this panel (I selected the trinket's port, which is why it became the selected board at the bottom)
vsc-code-running.jpg
vsc-code-running.jpg (66.62 KiB) Viewed 119 times

User avatar
LukeR
 
Posts: 14
Joined: Sun May 15, 2022 2:56 pm

Re: Visual Studio Code not recognizing CircuitPython library

Post by LukeR »

I am not sure exactly what fixed my problem, but it is working now. Thanks for the help.

A bit off-topic, but does anyone know how to set up ethernet for a local network? I need to define a specific port and the server IP address. The only examples that I have been able to find have used a website URL, and don't define a port. This will not work for my application.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Visual Studio Code not recognizing CircuitPython library

Post by mikeysklar »

LukeR,

Please start a new thread for the ethernet question.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”