syntax error near unexpected token `(' python script

Blue Moon

I am running a python code that has to interact between a windows machine and a linux machine.

The code is launched on windows, the computations are performed by the server, and the result comes back in a folder on windows.

When I run the code on my Windows machine is fine but when this is passed through the linux server I get the following error message:

 line 25: syntax error near unexpected token `('
 line 25: `db = MySQLdb.connect(host="192.168.1.18", # host

while the line of code is:

 db = MySQLdb.connect(host="192.168.1.18", # host

What does the error message mean and how to solve it?

Thanks

Andrea Corbellini

The Python file needs to be executed by the Python interpreter.

You can do e.g.:

python script.py

where script.py is the name of your file.

What you are doing instead is running your Python script through Bash (in fact, what you are getting is a typical Bash error). Probably this is happening because you are using ./script.py, but your script is missing the correct shebang line:

#!/usr/bin/env python

Indeed, if yours is a Python 3 script, you should use python3 instead of python.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Syntax error near unexpected token 'then'

From Dev

Syntax error near unexpected token 'then' in shell script

From Dev

Bash script: syntax error near unexpected token?

From Dev

Getting "syntax error near unexpected token `fi'" in my bash script

From Dev

Bash Script: syntax error near unexpected token `else'

From Dev

Syntax error near unexpected token 'fi', bash script

From Dev

syntax error near unexpected token `}' `

From Dev

Syntax error near unexpected token `='()

From Dev

syntax error near unexpected token `<'

From Dev

syntax error near unexpected token `then'

From Dev

syntax error near unexpected token `do' in bash script

From Dev

Syntax error near unexpected token `('

From Dev

Shell Script - syntax error near unexpected token `else'

From Dev

syntax error near unexpected token `<' for shell script block in Jenkinsfile

From Dev

Syntax error near unexpected token `('

From Dev

Shell Script - syntax error near unexpected token `else'

From Dev

Syntax error near unexpected token `('

From Dev

syntax error near unexpected token `<'

From Dev

syntax error near unexpected token `('

From Dev

Bash script: syntax error near unexpected token?

From Dev

syntax error near unexpected token `}'

From Dev

Syntax error near unexpected token '{'

From Dev

Syntax error near unexpected token '('

From Dev

Bash script: syntax error near unexpected token `('

From Dev

Python - syntax error near unexpected token `|'

From Dev

Bash script error: line 167: syntax error near unexpected token 'then'

From Dev

git removal script throwing error: syntax error near unexpected token `('

From Dev

syntax error near unexpected token `

From Dev

Syntax error near unexpected token `then'

Related Related

HotTag

Archive