pycorpora icon indicating copy to clipboard operation
pycorpora copied to clipboard

ImportError: cannot import name plants

Open quintendewilde opened this issue 7 years ago • 7 comments

After succesfully installing pycorpora thru pip, I still get following error.

ImportError: cannot import name plants

This following the example from main page pycorpora

Even the standard usage example doesn't work?

print random.choice(pycorpora.plants.flowers['flowers'])

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'plants

Is there something I still need to install in my python path from pycorpora?

quintendewilde avatar Mar 02 '17 14:03 quintendewilde

I tested and this was working with my already-installed 0.1.1, but after upgrading (pip install -U pycorpora) to 0.1.2 I can reproduce this problem.

Downgrading back to 0.1.1 (pip install pycorpora==0.1.1) doesn't fix it.

I didn't see Installing corpora data from printed during either installation, so the problem's somewhere in there.


Full logs:

$ python 1.py
violets
farmhouse

$ pip install -U pycorpora
Collecting pycorpora
  Downloading pycorpora-0.1.2.tar.gz
  Building wheels for collected packages: pycorpora
  Running setup.py bdist_wheel for pycorpora ... done
  Stored in directory: /Users/hugo/Library/Caches/pip/wheels/44/7f/cf/53bc878f9b48e83e07dd7d61936761a5bf5efc6bd6b968345d
Successfully built pycorpora
Installing collected packages: pycorpora
  Found existing installation: pycorpora 0.1.1
    Uninstalling pycorpora-0.1.1:
      Successfully uninstalled pycorpora-0.1.1
Successfully installed pycorpora-0.1.2

$ python 1.py
Traceback (most recent call last):
  File "1.py", line 5, in <module>
    print random.choice(pycorpora.plants.flowers['flowers'])
AttributeError: 'module' object has no attribute 'plants'

$ pip install pycorpora==0.1.1
Collecting pycorpora==0.1.1
  Downloading pycorpora-0.1.1.tar.gz
Building wheels for collected packages: pycorpora
  Running setup.py bdist_wheel for pycorpora ... done
  Stored in directory: /Users/hugo/Library/Caches/pip/wheels/97/5e/ae/6d4cf048e5a83c709f4e2b4412e567f23604e3ecee5dc974ae
Successfully built pycorpora
Installing collected packages: pycorpora
  Found existing installation: pycorpora 0.1.2
    Uninstalling pycorpora-0.1.2:
      Successfully uninstalled pycorpora-0.1.2
Successfully installed pycorpora-0.1.1

$ python 1.py 
Traceback (most recent call last):
  File "1.py", line 5, in <module>
    print random.choice(pycorpora.plants.flowers['flowers'])
AttributeError: 'module' object has no attribute 'plants'

hugovk avatar Mar 02 '17 20:03 hugovk

Uninstalling pycorpora and installing from a clone works:

$ git clone https://github.com/aparrish/pycorpora
$ cd pycorpora
$ python setup.py install
...

copying build/lib/pycorpora/data/words/stopwords/bg.json -> /usr/local/lib/python2.7/site-packages/pycorpora/data/words/stopwords
copying build/lib/pycorpora/data/words/stopwords/cs.json -> /usr/local/lib/python2.7/site-packages/pycorpora/data/words/stopwords
copying build/lib/pycorpora/data/words/stopwords/da.json -> /usr/local/lib/python2.7/site-packages/pycorpora/data/words/stopwords
c
...

So the problem is with installing via PyPI.

hugovk avatar Mar 02 '17 20:03 hugovk

This is related to issue #8. For now, the workaround is to use the following command when installing with pip:

pip install --no-cache-dir pycorpora

aparrish avatar Mar 02 '17 21:03 aparrish

I just updated the README with this information, which should hopefully prevent future confusion. Leaving this issue open as a reminder of how dire the problem is :(

aparrish avatar Mar 02 '17 21:03 aparrish

I've tried manual install and the pip no cache install, still when import pycorpora no error, when import plants it gives me the error no such module.

quintendewilde avatar Mar 03 '17 14:03 quintendewilde

@BLCKPSTV you may need to completely remove the module and re-install (making sure to also uninstall any globally-installed versions).

aparrish avatar Mar 03 '17 19:03 aparrish

Sorry how do I do that, uninstalling globally?

I did get it working on my Imac so the cloning/installing installation from hugovk did work for me!

quintendewilde avatar Mar 07 '17 18:03 quintendewilde