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
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.
Comments