muatik / naive-bayes-classifier

yet another general purpose naive bayesian classifier.
MIT License
172 stars 72 forks source link

ImportError: No module named 'ExceptionNotSeen' #11

Open ForeverZyh opened 7 years ago

ForeverZyh commented 7 years ago

Maybe something is missing...

Traceback (most recent call last): File "/Users/ZhangYuhao/Documents/Datamining/project/Q_number.py", line 3, in from naiveBayesClassifier.trainer import Trainer File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/naiveBayesClassifier/trainer.py", line 1, in from naiveBayesClassifier.trainedData import TrainedData File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/naiveBayesClassifier/trainedData.py", line 1, in from ExceptionNotSeen import NotSeen ImportError: No module named 'ExceptionNotSeen'

Could anyone help me out?

pmahend1 commented 6 years ago

seems there is something wrong with the install import or python path in system variable.

Solve it this way

  1. Go to this folder /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/naiveBayesClassifier
  2. Copy ExceptionNotSeen.py to your current project path(where you run your main python program

It solved that issue for me.

ForeverZyh commented 6 years ago

Thks!

peachyDinosaur commented 6 years ago

Does not work in virtual environment (anaconda) Still getting thrown the same error Naive Bayes Classifier has the ExceptionNotFound in its folder Tried storing the file locally in the project directory but it's not working

pmahend1 commented 6 years ago

you need to import class NotSeen into all dependent class files. Add from ExceptionNotSeen import NotSeen in all relevent files under C:\Users\Username\AppData\Local\Programs\Python\Python36\Lib\site-packages\naiveBayesClassifier

I did that to

It should solve your issue

peachyDinosaur commented 6 years ago

All files already make this import

pmahend1 commented 6 years ago

whats the error message you are getting ? post it here

iTiPo commented 6 years ago

I am getting the following error with Anaconda:

Traceback (most recent call last):
  File "cat.py", line 6, in <module>
    from naiveBayesClassifier.trainer import Trainer
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\naiveBayesClassifier\trainer.py", line 1, in <module>
    from naiveBayesClassifier.trainedData import TrainedData
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\naiveBayesClassifier\trainedData.py", line 1, in <module>
    from ExceptionNotSeen import NotSeen
ModuleNotFoundError: No module named 'ExceptionNotSeen'
peachyDinosaur commented 6 years ago
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-29-cd130a80dcb6> in <module>()
     10 import textacy
     11 import textacy.datasets
---> 12 from genderizer.genderizer import Genderizer
     13 get_ipython().run_line_magic('matplotlib', 'inline')

~/anaconda3/envs/nlp/lib/python3.6/site-packages/genderizer/genderizer.py in <module>()
      4 
      5 from naiveBayesClassifier import tokenizer
----> 6 from naiveBayesClassifier.trainer import Trainer
      7 from naiveBayesClassifier.classifier import Classifier
      8 

~/anaconda3/envs/nlp/lib/python3.6/site-packages/naiveBayesClassifier/trainer.py in <module>()
----> 1 from naiveBayesClassifier.trainedData import TrainedData
      2 
      3 class Trainer(object):
      4 
      5     """docstring for Trainer"""

~/anaconda3/envs/nlp/lib/python3.6/site-packages/naiveBayesClassifier/trainedData.py in <module>()
----> 1 from ExceptionNotSeen import NotSeen
      2 
      3 class TrainedData(object):
      4     def __init__(self):
      5         self.docCountOfClasses = {}

ModuleNotFoundError: No module named 'ExceptionNotSeen'
pmahend1 commented 6 years ago

Not sure about anaconda or virtual environment.

I would cross check for ExceptionNotSeen.py file in C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\naiveBayesClassifier directory.

Also check whether ExceptionNotSeen.py has been define as below

class NotSeen(Exception):
    """
    Exception for tokens which are not indexed 
    because never seen in the trainin data
    """
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return "Token '{}' is never seen in the training set.".format(self.value)

And

Add from ExceptionNotSeen import NotSeen in all relevent files classifier.py , trainedData.py in same directory too.

Anki89 commented 6 years ago

i got the same error. C:\Users\user\Desktop\amazonscrapy-master\AmazonScrapy\spiders>python amazon_spider.py Traceback (most recent call last): File "amazon_spider.py", line 13, in from AmazonScrapy.items import AmazonscrapyItem ModuleNotFoundError: No module named 'AmazonScrapy'

Darahaas commented 6 years ago

Is the version of python that many of you are using is 3.x? If so, download 2to3, copy 2to3 file to dir of genderizer package, then open the terminal in genderizer package dir and run the following command:

2to3 -w .

which converts all the python files to the version 3. This should solve all the above problems and this has worked for me!

Chinenana commented 5 years ago

the same error。。。。

Chinenana commented 5 years ago

seems there is something wrong with the install import or python path in system variable.

Solve it this way

It solved that issue for me.

I don't have this file(.py)

karmelyoei commented 3 years ago

You can try this " from naiveBayesClassifier.ExceptionNotSeen import NotSeen " it worked for me in all required files