aparrish / pycorpora

A simple Python interface for Darius Kazemi's Corpora Project.
MIT License
119 stars 24 forks source link

ImportError: cannot import name plants #14

Open quintendewilde opened 7 years ago

quintendewilde commented 7 years ago

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?

hugovk commented 7 years ago

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 commented 7 years ago

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.

aparrish commented 7 years ago

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 commented 7 years ago

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 :(

quintendewilde commented 7 years ago

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.

aparrish commented 7 years ago

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

quintendewilde commented 7 years ago

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!