Python Forum
SyntaxError: from simple python example file from mind-monitor code (muse 2)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: from simple python example file from mind-monitor code (muse 2)
#1
Sad 
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.
Reply
#2
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.
Reply
#3
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.
Reply
#4
(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!
Reply
#5
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  My simple code don't works !! Nabi666 1 185 Sep-06-2021, 12:10 PM
Last Post: jefsummers
  Plotting sum of data files using simple code Laplace12 3 678 Jun-16-2021, 02:06 PM
Last Post: BashBedlam
  Request for Python code - Features extraction from JSON file (cuckoo) thinker 1 542 Apr-07-2021, 04:40 PM
Last Post: Larz60+
  Using a .bat file to execute simple anaconda commands in Windows 10 gacg1 0 1,092 Nov-30-2020, 03:24 PM
Last Post: gacg1
  Skeleton file export error Python Code pepapoha 4 1,291 Nov-17-2020, 02:06 AM
Last Post: pepapoha
  "SyntaxError: invalid syntax" running code in Doing Math With Python b saucerdesigner 2 744 Nov-03-2020, 04:23 PM
Last Post: saucerdesigner
  Simple plotting from txt file Laplace12 2 703 Aug-23-2020, 09:58 AM
Last Post: Laplace12
  [split] SyntaxError when trying to execute code on Windows nehaya 2 682 Aug-04-2020, 11:18 AM
Last Post: nehaya
  Learning python SyntaxError: 'return' outside function Grale1953 3 940 Aug-03-2020, 06:55 AM
Last Post: buran
  Help with isinstance command (very simple code) Laplace12 2 685 Jul-30-2020, 05:26 AM
Last Post: Laplace12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020