cltk / tutorials

Tutorials for the CLTK
MIT License
52 stars 28 forks source link

ModuleNotFoundError: No module named 'cltk.corpus' (resolved from previous query) #26

Closed brooksca3 closed 3 years ago

brooksca3 commented 3 years ago

In the jupyter notebook in my virtual environment, I try to run the line of code: from cltk.corpus.utils.importer import CorpusImporter and get the warning 'ModuleNotFoundError: No module named 'cltk.corpus'.

I try the same thing on Google colab and have the same issue.

cltk has been successfully installed in both cases. Do you have any advice for this issue?

I noticed someone else has the same unresolved issue here: https://stackoverflow.com/questions/67513247/cltk-module-in-python

kylepjohnson commented 3 years ago

Wow we've made it to SO :)

These notebooks are for the previous major version. They haven't been updated for 1.0 yet. You can see use examples here, though: https://github.com/cltk/cltk/tree/master/notebooks

Sorry about the confusion. With the switch to 1.0, our docs are out of step.

brooksca3 commented 3 years ago

Thank you for the help @kylepjohnson !

One issue I can't seem to solve going through the example steps -

I have replicated all the steps, and have an issue with the line: cltk_doc = cltk_nlp.analyze(text=livy) and I have the following problem:

Screen Shot 2021-06-16 at 12 59 32 PM

It looks like this might be a problem with Latin not having MWTs? Not sure if this is a problem with Stanza and unrelated to cltk, but was wondering if you have any advice for fixing.

Thanks again!

kylepjohnson commented 3 years ago

@diyclassics I don't recall seeing this issue in the main repo. Did I miss it?

@brooksca3 would you please fill out this info for me here?

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Install Python version …
  2. Install CLTK version … with …
  3. In a script or REPL, run the following code … (include literal copy-paste)
  4. See error (include literal copy-paste)

Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

kylepjohnson commented 3 years ago

^ Specifically want to know your OS, what vers Python, and how you installed

kylepjohnson commented 3 years ago

I need a way to reproduce this locally. What if you rm everything at ~/stanza_resources then try again?

brooksca3 commented 3 years ago

Thank you for having a look! I have been following the instructions step by step from here: https://github.com/cltk/cltk/blob/master/notebooks/CLTK%20Demonstration.ipynb

Describe the bug: When running the cell In[12] in the instructions linked above, I get an error as seen in the photo above.

To Reproduce: Earlier I was just using Google colab, but have tried also on jupyter notebook in a virtual environment and am having the same issue. I'll describe what I did with the second approach.

I'm using python 3.9.2 on Mac OS Catalina 10.15.5, cltk Version: 1.0.15

I cd'ed enter a directory I called cltk, pip installed cltk and jupyter, then entered 'source env/bin/activate' to set up the virtual environment, then 'jupyter notebook' to work there. I then copied the code from the example notebook.

The line of code itself is: %time cltk_doc = cltk_nlp.analyze(text=livy) The error message is: TypeError: argument of type 'NoneType' is not iterable (I'll add a screenshot to include everything)

I tried removing everything at ~/stanza_resources and had the same issue.

Thank you for taking the time to help out with this!

Screen Shot 2021-06-16 at 9 01 36 PM Screen Shot 2021-06-16 at 9 00 43 PM
todd-cook commented 3 years ago

The error mentioned occurs in the stanza library code, which CLTK wraps, but we use a pinned version.

@brooksca3 So it looks like somehow you have stanza 1.2.1 installed. Please downgrade to 1.1.1, via running: pip install stanza==1.1.1 should do it. Also, sadly, if you have downloaded any 1.2.1 models outside of CLTK, they will not work the with 1.1.1 version, but CLTK will download the correct ones. We will continue to try to work with the stanza folks, but in order guarantee a working, robust version of CLTK, we must resort to pinned versions. Let me know if this doesn't solve your problem, otherwise closing this ticket.

kylepjohnson commented 3 years ago

Todd, thank you, I should have thought of that.

In pyproject.toml, stanza must be pinned here: https://github.com/cltk/cltk/blob/master/pyproject.toml#L42

Gonna see if I can bump this from my phone

diyclassics commented 3 years ago

The error message is: TypeError: argument of type 'NoneType' is not iterable

Confirming that I was able to reproduce this error (MacOS 11.4; Python 3.9.5; CLTK 1.0.14) and that, per the solution suggested above by @todd-cook, downgrading to Stanza 1.1.1 and reloading the models solved the problem.

kylepjohnson commented 3 years ago

New version pushed. Thank you @brooksca3 !

You can upgrade to it with: pip install -U cltk. If that doesn't work, of course let us know.

brooksca3 commented 3 years ago

Thank you everyone! Running smoothly now

BJWipf commented 2 years ago

I'm having maybe a similar issue getting access to corpora.

I get the same error of as OP with from cltk.corpus.utils.importer import CorpusImporter

When I follow the "Get Data" directions, I get the following

image

Cell 40 runs fine, but the error comes in 41.

Any thought as to what I'm doing wrong? TIA!

kylepjohnson commented 2 years ago

Uncomment that curl command and run again, let us know if that gets you the file. 

Feb 12, 2022, 15:06 by @.***:

I'm having maybe a similar issue getting access to corpora.

I get the same error of as OP with > from cltk.corpus.utils.importer import CorpusImporter

When I follow the "Get Data" directions, I get the following

https://user-images.githubusercontent.com/42853260/153731626-aa49a33d-2a4a-4356-9e67-fcb6f78b9f77.png

Cell 40 runs fine, but the error comes in 41.

Any thought as to what I'm doing wrong? TIA!

— Reply to this email directly, > view it on GitHub https://github.com/cltk/tutorials/issues/26#issuecomment-1037558083> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/AAOE36AOHB5EYTZ4DNYVX2LU23RWBANCNFSM46X57RCQ> . Triage notifications on the go with GitHub Mobile for > iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or > Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub> . You are receiving this because you modified the open/close state.> Message ID: > <cltk/tutorials/issues/26/1037558083> @> github> .> com>

BJWipf commented 2 years ago

Thank you! I'm clearly far from an expert and appreciate the assistance. The "get data" demonstration is now working, but I'm getting the same error with from cltk.corpus.utils.importer import CorpusImporter

What am I doing wrong/missing here?

image

kylepjohnson commented 2 years ago

Ahhh, I see what's happening. We're in the tutorials repo -- I did not see that when replying by email yesterday. One sec, I am going to move this issue and your questions will be answered, I think.