stanford_corenlp_pywrapper
stanford_corenlp_pywrapper copied to clipboard
python 3 - no module named sockwrap
I am running this with python 3.4 and after installing when I run following command
from stanford_corenlp_pywrapper import CoreNLP
I get an error
File "/Volumes/anupam_work/test/stanford_corenlp_pywrapper/stanford_corenlp_pywrapper/init.py", line 1, in
So how can this be resolved?
it might be relative imports? i've only tested this with 2.7. i seem to recall python 3 changed that stuff somehow.
+1
+1
In order to import the code using with Python 3, I had to make a couple of changes:
- Line 1 of init.py, change "from sockwrap import *" to "from .sockwrap import *"
- Line 194 of sockwrap.py, change "except socket.error, e" to "except socket.error as e"
- Line 254 of sockwrap.py, change "except socket.timeout, e" to "except socket.timeout as e"
- Lines 332 and 348, add parentheses around the print function argument.
I did some preliminary checking, and more changes may be needed to get the entire module working.
@mauryquijada thanks! There is also a print parenthesis missing in line 352
Thanks guys for corrections.
Line 1 of init.py, change "from sockwrap import *" to "from .sockwrap import *" Line 194 of sockwrap.py, change "except socket.error, e" to "except socket.error as e" Line 254 of sockwrap.py, change "except socket.timeout, e" to "except socket.timeout as e" Lines 332, 348 and 352 add parentheses around the print function argument
Thanks, it worked for me too.