ImportError: No module named pyb

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
55thSwiss
Posts: 5
Joined: Sun Dec 09, 2018 3:02 pm

ImportError: No module named pyb

Post by 55thSwiss » Sat Dec 15, 2018 12:00 pm

I was under the impression the pyb module came standard on the pyboard? I started it up this morning (for the first time mind you), and the root directly appeared without a problem after installing the new driver software I was able to view and execute the internal scripts (main.py and boot.py). I'm interested in using an external I2C, so I started with "from pyb import I2C" of course, but it generates an error immediately (same as subject line). Can someone direct me if I'm misunderstanding something The import command was obviously taken from https://docs.micropython.org/en/latest/ ... b.I2C.html :?

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

Re: ImportError: No module named pyb

Post by Roberthh » Sat Dec 15, 2018 2:15 pm

Which pyboard and which firmware are you using. You get the information py pushing Ctrl-B at the REPL prompt.

55thSwiss
Posts: 5
Joined: Sun Dec 09, 2018 3:02 pm

Re: ImportError: No module named pyb

Post by 55thSwiss » Sat Dec 15, 2018 5:36 pm

Is it required to use a REPL terminal? The Pyboard is going to be monitored through a Raspberry Pi (the pyboard is plugged into it) so I had just navigated to the pyboard thru the RPi, edited the main.py from there and ran in thru the python terminal that is already on Rasbian. I'm wondering if this is my problem? General code seems to run fine but importing does not.

I will be home shortly to answer your original question if I can

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

Re: ImportError: No module named pyb

Post by Roberthh » Sat Dec 15, 2018 7:21 pm

There is no need for a specific terminal, just some means to pick up the messages sent by the pyboard through its cdc interface, the same path which told you the error messages.

55thSwiss
Posts: 5
Joined: Sun Dec 09, 2018 3:02 pm

Re: ImportError: No module named pyb

Post by 55thSwiss » Sat Dec 15, 2018 9:07 pm

So running from a .py file and using the terminal that opens (where the exception was written and has lines like a REPL terminal (>>>)) is not the same thing. I'm working on how to open REPL on a Raspberry Pi right now. Sorry for the delay

rhubarbdog
Posts: 113
Joined: Tue Nov 07, 2017 11:45 pm

Re: ImportError: No module named pyb

Post by rhubarbdog » Sun Dec 16, 2018 4:37 am

the program yon need for REPL on raspberry pi is screen. Download and install it by typing

Code: Select all

sudo apt-get screen
To enter a REPL session type

Code: Select all

screen /dev/ttyACM0
To exit press CTRL+A, \, then answer yes to the question. Pressing CTRL+A, CTRL+D gets you back to a command prompt, but you haven't terminated screen. You've detached from screen to reattatch and terminate properly type

Code: Select all

screen -r

Post Reply