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
  Help with simple code JacobSkinner 1 227 Mar-18-2024, 08:08 PM
Last Post: deanhystad
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 440 Nov-07-2023, 04:32 PM
Last Post: snippsat
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,164 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  help me simple code result min and max number abrahimusmaximus 2 869 Nov-12-2022, 07:52 AM
Last Post: buran
  Simple encoding code ebolisa 3 1,399 Jun-18-2022, 10:59 AM
Last Post: deanhystad
  Problem with importing Python file in Visual Studio Code DXav 7 4,903 Jun-15-2022, 12:54 PM
Last Post: snippsat
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,129 Feb-25-2022, 06:31 PM
Last Post: jao
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 1,751 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,353 Feb-13-2022, 07:13 PM
Last Post: menator01
  Simple code question about lambda and tuples JasPyt 7 3,238 Oct-04-2021, 05:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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