question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MC2221A import board RuntimeError: already open

See original GitHub issue

Hello,

When running following python code import os; os.environ['BLINKA_MCP2221'] = '1' import os; os.environ['BLINKA_MCP2221_RESET_DELAY'] = '0.5' import board

I get following error:

Traceback (most recent call last): File “c:\Users\Nick\Desktop\mc2221a.py”, line 8, in <module> import board File “C:\Python39\lib\site-packages\board.py”, line 182, in <module> from adafruit_blinka.board.microchip_mcp2221 import * File “C:\Python39\lib\site-packages\adafruit_blinka\board\microchip_mcp2221.py”, line 5, in <module> from adafruit_blinka.microcontroller.mcp2221 import pin File “C:\Python39\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\pin.py”, line 5, in <module> from .mcp2221 import mcp2221 File “C:\Python39\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py”, line 389, in <module> mcp2221 = MCP2221() File “C:\Python39\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py”, line 58, in init self._reset() File “C:\Python39\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py”, line 128, in _reset self._hid.open(MCP2221.VID, MCP2221.PID) File “hid.pyx”, line 111, in hid.device.open RuntimeError: already open

If I just set environment variable and open a Python shell and just type “import board” I get same exact error as above.

If I try to use PyMCP2221A module to communicate with my MCP221A device instead, it seems to be working fine. “MCP2221 I2C/SMBus Terminal” utility also seems to be working fine (I can read data via I2C protocol)

I’m using latest version of adafruit-blinka (7.1.1) & hidapi (0.11.2). I was using following guide to set everything up: https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221/windows My environment is Windows 11

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nickGermicommented, Apr 28, 2022

I can confirm upgrading from installed adafruit-blinka-7.1.2 to adafruit-blinka-7.2.2 fixed the issue, after the upgrade setting BLINKA_MCP2221_RESET_DELAY to -1, 0.5 or not setting any value at all works fine.

0reactions
caternusoncommented, Apr 25, 2022

Please try updating to the 7.2.2 release of Blinka: https://github.com/adafruit/Adafruit_Blinka/releases/tag/7.2.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · adafruit/Adafruit_Blinka - GitHub
Beaglebone Black: Import Board Fails with "No module named ... RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported) neopixel.
Read more >
CircuitPython Libraries on any Computer with MCP2221
This guide will show you how to use an MCP2221(A) to connect to I2C sensors and breakouts from your desktop PC running Windows,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found