OpenBCI_LSL Streaming error: ModuleNotFoundError: No module named 'serial'
Hi there,
When I'm trying to streaming my signals from GUI session to Python, an error comes out on the cmd board: 'ModuleNotFoundError: No module named 'serial''. Should I specify my port serial by entering 'python openbci_lsl.py [PORT] --stream'? If yes, how I can specify it? Thank you.
Comments
Hi, you need to install serial separately.
Use the following command:
pip install serialMostly if you error like this, ** ModuleNotFoundError: No module named 'name of import file** it means that module is not found in your installed libraries:
First, You need to install that package, for using that in your code.
@Doris, hi.
Both of the Python repos below have been deprecated and are no longer supported.
https://github.com/openbci-archive/OpenBCI_LSL
https://github.com/openbci-archive/pyOpenBCI
Instead of using these repositories, it is now recommended to use Brainflow instead.
https://brainflow.org/
Regards, William
Thanks a lot for answering. I'm using the brainflow now, but when I tried to read from the board using the sample code provided, error show:'raise BrainFlowError ('unable to prepare streaming session', res)
brainflow.board_shim.BrainFlowError: UNABLE_TO_OPEN_PORT_ERROR:2 unable to prepare streaming session'. I have installed serial via pip, which sadly still not working. I believe something wrong with my serial port, could you help please?
It's unable to open a Serial port, likely because you are using it elsewhere. Serial ports can only be used by one application at a time.
Hi, once I stop the session, I can get the readings from the board. But this means that the data is not in real time, but is in pending, right?
Can you rephrase with more detail, such as:
"once I stop the [GUI] session, I can get the [Brainflow] readings from board." Etc.
"...this means that the data is not in real time, but is pending..."
Both the GUI access and Brainflow access are real time.
William
Yes, so when I keep the session running, which means both the data stream and LSL stream are on, I get the error on cmd:''raise BrainFlowError ('unable to prepare streaming session', res)
brainflow.board_shim.BrainFlowError: UNABLE_TO_OPEN_PORT_ERROR:2 unable to prepare streaming session' as I mentioned before. The reason causes this error is that COM is occupied so python can't read from the serial port. Therefore, I stop the whole session of GUI and run cmd as: 'C:\windows\system32>python C:\Users\example.py --board-id 0 --serial-port COM3 ----streamer-param "file://test.txt:w" ', then I have txt file in the folder. That's the thing confuses me, where I think the data in the txt file is not in real time.
Additionally, my aim is to plot the EEG signals on python via GUI in REAL TIME. Cheers.
As Richard previously pointed out, only ONE process can open the serial port at a time. The process that DOES have the port open, and is reading the stream and recording, or doing other operations -- is indeed operating in real time.
"That's the thing confuses me, where I think the data in the txt file is not in real time."
Again, I don't understand what you are saying. When the GUI or the Brainflow programs are successfully running, they are doing so in real time. However the recording file created in real time, is subject to buffering constraints. And thus the data in the file may not be showing up in real time. Instead the data appears in the file, only when the program flushes it's buffer to the hard drive.
Does that make sense? In the case of the Brainflow program, YOU can control when these flushes happen.
Your other option for outputting an LSL stream (from the GUI), is to use the Networking Widget in the GUI.