ModuleNotFoundError: No module named 'pyb'

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
spoetnic
Posts: 9
Joined: Sun Dec 08, 2019 12:08 pm

ModuleNotFoundError: No module named 'pyb'

Post by spoetnic » Tue Feb 11, 2020 2:19 pm

Hello, I'm just new to micropython and I just managed to get python installed on microsoft code.
Now I've connected my pyboard 1.1 and try to run a default program.
The first error I hit is: ModuleNotFoundError: No module named 'pyb'

I hope someone can help solving this? Thanks.

User avatar
dhylands
Posts: 3452
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: ModuleNotFoundError: No module named 'pyb'

Post by dhylands » Tue Feb 11, 2020 5:45 pm

Which board are you using? The pyb module exists on the stm32 port, and doesn't exist on the ESP32 and ESP8266 ports.

The general preference is to use the machine module where possible.

spoetnic
Posts: 9
Joined: Sun Dec 08, 2019 12:08 pm

Re: ModuleNotFoundError: No module named 'pyb'

Post by spoetnic » Thu Feb 13, 2020 8:45 am

Hi, I'm using the pyboard 1.1. So this is with the STM32405RG. I'm trying to upload an code to the board from VSCODE. The board is connected, but when trying to RUN it says:

PS C:\Users\Marc Frim> & "C:/Users/Marc Frim/AppData/Local/Programs/Python/Python38-32/python.exe" "c:/Users/Marc Frim/.vscode/extensions/rt-thread.rt-thread-micropython-1.0.7/microExamples/examples/03.board/5.pyboard/blink.py"
Traceback (most recent call last):
File "c:/Users/Marc Frim/.vscode/extensions/rt-thread.rt-thread-micropython-1.0.7/microExamples/examples/03.board/5.pyboard/blink.py", line 2, in <module>
import pyb
ModuleNotFoundError: No module named 'pyb'
PS C:\Users\Marc Frim>

User avatar
jimmo
Posts: 1833
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ModuleNotFoundError: No module named 'pyb'

Post by jimmo » Thu Feb 13, 2020 12:23 pm

It looks like it's trying to run in regular Python (i.e. CPython) rather than on the pyboard.

spoetnic
Posts: 9
Joined: Sun Dec 08, 2019 12:08 pm

Re: ModuleNotFoundError: No module named 'pyb'

Post by spoetnic » Tue Feb 18, 2020 11:34 am

Indeed I did install python, RT-Thread MicroPython and Pymakr into VS code. Still I'm getting this error: ModuleNotFoundError: No module named 'pyb' when pressing RUN.

fillofonta
Posts: 7
Joined: Mon Jul 13, 2020 8:55 am

Re: ModuleNotFoundError: No module named 'pyb'

Post by fillofonta » Thu Jul 30, 2020 7:00 am

i'm having a similar problem with pycharm, the error is the following :
DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
ERROR: Could not find a version that satisfies the requirement pyb (from versions: none)
ERROR: No matching distribution found for pyb
I am able to install other libraries of micropython

User avatar
jimmo
Posts: 1833
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ModuleNotFoundError: No module named 'pyb'

Post by jimmo » Thu Jul 30, 2020 9:20 am

You don't need to pip install the pyb module, it's included in the firmware.

fillofonta
Posts: 7
Joined: Mon Jul 13, 2020 8:55 am

Re: ModuleNotFoundError: No module named 'pyb'

Post by fillofonta » Thu Jul 30, 2020 9:22 am

how do i use it then? when i write it i get Unresolved reference 'pyb'

Online
User avatar
Roberthh
Posts: 2131
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ModuleNotFoundError: No module named 'pyb'

Post by Roberthh » Thu Jul 30, 2020 9:40 am

The pyb module only exists on Pyboard hardware. Which board are you using?

fillofonta
Posts: 7
Joined: Mon Jul 13, 2020 8:55 am

Re: ModuleNotFoundError: No module named 'pyb'

Post by fillofonta » Thu Jul 30, 2020 9:56 am

i am using a nucleo-f767zi, but shouldn't be able to mimport it anyway and not be able af use it??

Post Reply