vscode-circuitpython icon indicating copy to clipboard operation
vscode-circuitpython copied to clipboard

ModuleNotFoundError: No module named 'board'

Open christofeugster opened this issue 2 years ago • 5 comments

Describe the bug ModuleNotFoundError: No module named 'board' In VSC Console and more important when trying to initialize VSC debugging module 'board' is not found (i guess because it is on a different directory than VSC is looking for)

To Reproduce Steps to reproduce the behavior:

  1. Installed Circuitpyhon extension and (Python, Pylance, isort, Intellicode and API, Jupiter)
  2. Circuitpython and REPL works flawlessly except - Python Console has the ModuleNotFoundError
  3. Start Debugging, creating new json launch file
  4. Start Debugging
  5. Error occurs

Exception has occurred: ModuleNotFoundError (note: full exception trace is shown but execution is paused at: _run_module_as_main) No module named 'board' File "D:\main.py", line 3, in <module> import board File "C:\Users\****\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 88, in _run_code exec(code, run_globals) File "C:\Users\****\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 198, in _run_module_as_main (Current frame) return _run_code(code, main_globals, None,

Expected behavior VSC (Python, Pylance) should search module 'board' in the extraPaths i guess. c:\Users\****\.vscode\extensions\joedevivo.vscode-circuitpython-0.1.19-win32-x64\boards but instead is looking in stock python folder or D:\ drive directly

Desktop (please complete the following information):

  • OS: Windows 11
  • Latest Python
  • Latest Firmware - Adafruit Unexpected Maker Feather S3

Additional context

  • Ive tried to include directories in Pylance Settings. No luck
  • extra Paths are showing up in settings.json file.
  • In launch.json file i set "justMyCode": false - no difference

Any suggestions how to make VSC debugging work for Circuitpython? Thanks and best regards Chris

christofeugster avatar Dec 28 '22 11:12 christofeugster

Use git and pull this repo and then go into the downloaded files, vscode-circuitpython/scripts

Then in the scripts directory go and edit build-stubs.sh and at the bottom, rem out " rm -rf stubs/board" and run the script it will rebuild stubs/boards. then go replace it in .vscode/extensions/joedevivo.vscode-circuitpython-0.1.19-linux-x64/ the boards/stubs folders with the newly created one then this will go away.

Also if the date in the path line in settings.json does not match the current bundle you will get this problem, correct the date or erase .vscode and if have a workplace file erase it and let it all be rebuilt will correct it for a bad date scenario

wmerkens avatar Feb 04 '23 17:02 wmerkens

Use git and pull this repo and then go into the downloaded files, vscode-circuitpython/scripts

Then in the scripts directory go and edit build-stubs.sh and at the bottom, rem out " rm -rf stubs/board" and run the script it will rebuild stubs/boards. then go replace it in .vscode/extensions/joedevivo.vscode-circuitpython-0.1.19-linux-x64/ the boards/stubs folders with the newly created one then this will go away.

Also if the date in the path line in settings.json does not match the current bundle you will get this problem, correct the date or erase .vscode and if have a workplace file erase it and let it all be rebuilt will correct it for a bad date scenario

I found your YouTube vid as well as this - solved it for me, thanks @wmerkens !

cwgphillips avatar Feb 10 '23 22:02 cwgphillips

Are there any plans to make this a permanent fix? I would much rather use vscode than mu but it's kind of counterintuitive if you have to edit the extension files manually.

KristenLeach avatar Jan 02 '24 17:01 KristenLeach

I would like to see a button in VSC that, when you click it, or an option you run via the F1 menu to rebuild stubs/boards and put them in place. Also, I don't know why the file "board" is removed.

wmerkens avatar Jan 02 '24 23:01 wmerkens

Same problem. I am new to this and I guess I'm assuming that you are not intended to be able to run circuitpython code within VS code or do actual debugging, which has me at a loss for words.

Is there really no fix for this besides the complicated stuff above? I didn't do anything weird I swear. This is normal install stuff.

CombatVolcano avatar Jul 26 '24 10:07 CombatVolcano