ModuleNotFoundError : no module named 'pycorenlp'

1.8k views Asked by At

I need to install python wrapper for StanfordCoreNLP.

I have used git clone https://github.com/smilli/py-corenlp and also pip install pycorenlp and its showing success in both the cases, but when I run from pycorenlp import StanfordCoreNLP, its showing ModuleNotFoundError. I checked its path if it installed or not. It is installed at "C:\Users\simra_000\Anaconda3\Lib\site-packages\pycorenlp" using pip and using git clone also it is installed at "C:\Users\simra_000\py-corenlp"

from pycorenlp import StanfordCoreNLP

Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'pycorenlp'

1

There are 1 answers

3
Mr.mb On

check if the module was installed by:

pip list

also you can add this code to install the module if it's not installed:

import pip

required_pkgs = ['pycorenlp']
installed_pkgs = [pkg.key for pkg in pip.get_installed_distributions()]

for package in required_pkgs:
    if package not in installed_pkgs:
        with suppress_stdout():
            pip.main(['install', package])

also check the version of python that you are used to run the script and the version of pip, for example if you are using python3 and you install the module via pip (python2) the module was installed for python v.2 only

otherwise check the name of your script, so if the name of your script is pycorenlp.py the import will not work, and you need to change the name of your script hope that helps you