Python Forum

Full Version: SyntaxError: from simple python example file from mind-monitor code (muse 2)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working on a project using Muse 2, the brain wave detector. And I found the very simple code by James from mind-monitor.com and the app.
It looks pretty straight forward but somehow my Mac terminal cannot run it. This code should get the data from the app on my ipad/iphone via OSC and shown the visual graph.

I have posted this issue on the forum of https://mind-monitor.com/forums/viewforum.php?f=15
but they suggested I ask someone who knows python more. So here I am.

so..
The github of the example code is here:
https://github.com/Enigma644/MindMonitorPython

The code I'm trying is this one called "OSC Receiver Simple.py", which the URL is here:
https://github.com/Enigma644/MindMonitor...0Simple.py


I had changed the file name since the terminal says it cannot fine 'OSC' alone so I changed it to OSC-Receiver-Simple.py
Then, I got this error:

Error:
File "OSC-Receiver-Simple.py", line 13 def eeg_handler(address: str,*args): ^ SyntaxError: invalid syntax

NOTE* I can't put code snippet here. IDK why it is always shown as simple text. But anyway, the ^ of the error is shown at : aka colon.


I'm running on Mac
MacBook Pro (Retina, 15-inch, Mid 2014) Catalina 10.15.7
with python python2 2.7 and 3
and I already have that pip and done the "pip install python-osc"

Any suggestion of what might happen?
Thanks in advance.
You need to wrap code inside python tags (use Insert Python button).

There is not a syntax error in this line if you are using Python 3.5 or newer, but it is in Python 2.7. The ": str" is a type hint. It adds information to the function signature that can be used by some tools to help with autocompletion or code analysis. Type hints like this are relatively new to Python. You have a choice of installing a newer version of Python or doing A LOT of editing. Many things have changed since Python 2.7

I just looked at the package description and it mentions the 3.5+ requirement.
Quote:Open Sound Control server and client implementations in pure python (3.5+).

If your Python 3 version is 3.5 or newer, make sure you are running the code using python3 and not python.
You are running Python 2 which is 💀
Need to use Python 3 try with:
python3 OSC-Receiver-Simple.py
(Jul-16-2021, 02:11 PM)warmcupoftea Wrote: [ -> ]and I already have that pip and done the pip install python-osc
You may need to use pip3 test with pip -V and pip3 -V.
Look at The right and wrong way to set Python 3 as default on a Mac.
(Jul-16-2021, 02:35 PM)snippsat Wrote: [ -> ]You are running Python 2 which is 💀
Need to use Python 3 try with:
python3 OSC-Receiver-Simple.py
(Jul-16-2021, 02:11 PM)warmcupoftea Wrote: [ -> ]and I already have that pip and done the pip install python-osc
You may need to use pip3 test with pip -V and pip3 -V.
Look at The right and wrong way to set Python 3 as default on a Mac.

Thank you. I was reading and research on my error and found out that python3 did not work becuase of my xcode is out of date so I need to upgrade it. Anyway, your comment is a confirm that I need to use python3 thank you!
(Jul-16-2021, 02:24 PM)deanhystad Wrote: [ -> ]You need to wrap code inside python tags (use Insert Python button).

There is not a syntax error in this line if you are using Python 3.5 or newer, but it is in Python 2.7. The ": str" is a type hint. It adds information to the function signature that can be used by some tools to help with autocompletion or code analysis. Type hints like this are relatively new to Python. You have a choice of installing a newer version of Python or doing A LOT of editing. Many things have changed since Python 2.7

I just looked at the package description and it mentions the 3.5+ requirement.
Quote:Open Sound Control server and client implementations in pure python (3.5+).

If your Python 3 version is 3.5 or newer, make sure you are running the code using python3 and not python.

Thank you. I was reading and research my error and found out that python3 did not work because of my xcode is out of date so I need to upgrade it. Anyway, your comment is a confirmation that I need to use python3 thank you!