I downloaded the PythonOmekaApiToCsv directory to my computer and tried executing python omekacsv.py script and got the following error message:
file “omekacsv.py” , line 28
print 'exporting ’ + resource
SyntaxError: Missing parentheses in call to 'print
Am I suppose to change the information above so that the script will work or is there something else going on?
Thank you for your help.
Hmmm… this has the look of a Python version issue. Are you using Python 3? (Run
python --version if you’re not sure.) I’d wager that PythonOmekaApiToCsv is written for Python 2.
It’s a pretty simple script, so the process of having support for Python 3, or 2/3 simultaneously, is probably not too difficult.
I am using Python 3.5.2. Do I need to uninstall the latest version and install version 2 instead? Or is there another way for me to get the program to work? Thank you for your help!
Installing Python 2.7 should resolve this problem, yes.
The script can be rewritten somewhat to work with Python 3, but that won’t happen immediately.
One note: Python 3 is a well-known trouble spot and many distributions allow you to have both 2 and 3 installed simultaneously, either under different names or with some mechanism to switch between them.
The print command in python 3 is now a method and requires paratheses around the statement to be printed. Open the script in a text editor. Where the print statement is: print 'exporting ’ + resource change it to print('exporting ’ + resource).
Thank you very much. I have another question. I have tried executing the script but am getting error messages in regards to the following lines in the omekacsv.py file
from omekaclient import OmekaClient
from httplib2 import ServerNotFoundError
I replaced omekaclient with the domain url and I replaced httplib2 with domain url/items. Is that correct or am I not understanding what needs to be in those lines. Thank you for your help.
@tdahn is right about the specific error you posted, but there’s more to the Python 3 differences than just that error. The httplib2 error is because you don’t have the httplib2 package installed which is another easy fix, but there are bigger problems that create incompatibilities, like changes to how Python’s CSV support works between the versions.
My suggestion is still to use Python 2.7.
Thank you for your response. I am using Python 2.7 and am still getting an error message. So am I using the right syntax for the domain url and the httplib2?