stanford_corenlp_pywrapper icon indicating copy to clipboard operation
stanford_corenlp_pywrapper copied to clipboard

python 3 - no module named sockwrap

Open anupamme opened this issue 9 years ago • 8 comments

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 from sockwrap import * ImportError: No module named 'sockwrap'

So how can this be resolved?

anupamme avatar Oct 16 '15 11:10 anupamme

it might be relative imports? i've only tested this with 2.7. i seem to recall python 3 changed that stuff somehow.

brendano avatar Oct 16 '15 14:10 brendano

+1

FraBle avatar Mar 28 '16 23:03 FraBle

+1

elliottash avatar Apr 20 '16 23:04 elliottash

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 avatar Jul 08 '16 21:07 mauryquijada

@mauryquijada thanks! There is also a print parenthesis missing in line 352

shafy avatar Sep 13 '17 23:09 shafy

Thanks guys for corrections.

iamved avatar Mar 20 '18 18:03 iamved

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

sreenathelloti avatar Mar 26 '18 16:03 sreenathelloti

Thanks, it worked for me too.

ekegulskiy avatar Oct 14 '18 21:10 ekegulskiy