Working on code with CircuitPython libraries on Windows

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
mellowed
 
Posts: 2
Joined: Tue Jun 22, 2021 1:19 am

Working on code with CircuitPython libraries on Windows

Post by mellowed »

I'm working on a Python project on a Raspberry Pi Zero W that uses requests to get some data online, process that data, and display the results in the console. The pi is also hooked up to some neopixels with a level shifter and my code displays different colors based on those results.

I'd like to work on this code on my Windows laptop when I'm away from home. Of course from the very beginning with "import board" I get errors trying to run this on Windows. I end up commenting out all the CircuitPython and Neopixel code and then having to go back and undo all that before I put what I've changed back on the pi. I guess I'm looking for some general direction on how I could make code that would run both places without changes, bypassing the neopixel code and libraries if it's running on a device where they aren't hooked up.

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Working on code with CircuitPython libraries on Windows

Post by tannewt »

sys.platform can tell you what OS you are on. You can add conditions in your code around it: https://docs.python.org/3/library/sys.html#sys.platform

User avatar
mellowed
 
Posts: 2
Joined: Tue Jun 22, 2021 1:19 am

Re: Working on code with CircuitPython libraries on Windows

Post by mellowed »

tannewt wrote:sys.platform can tell you what OS you are on.
That got me going again. I appreciate your help.

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

Return to “Adafruit CircuitPython”