naive-bayes-classifier icon indicating copy to clipboard operation
naive-bayes-classifier copied to clipboard

ImportError: No module named 'ExceptionNotSeen'

Open ForeverZyh opened this issue 7 years ago • 14 comments

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?

ForeverZyh avatar Dec 05 '17 03:12 ForeverZyh

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.

pmahend1 avatar Dec 08 '17 18:12 pmahend1

Thks!

ForeverZyh avatar Dec 16 '17 07:12 ForeverZyh

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

peachyDinosaur avatar Dec 18 '17 17:12 peachyDinosaur

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

  • classifier.py
  • trainedData.py

It should solve your issue

pmahend1 avatar Dec 18 '17 18:12 pmahend1

All files already make this import

peachyDinosaur avatar Dec 19 '17 07:12 peachyDinosaur

whats the error message you are getting ? post it here

pmahend1 avatar Dec 20 '17 00:12 pmahend1

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'

iTiPo avatar Dec 21 '17 07:12 iTiPo

---------------------------------------------------------------------------
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'

peachyDinosaur avatar Dec 21 '17 20:12 peachyDinosaur

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.

pmahend1 avatar Jan 15 '18 02:01 pmahend1

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'

Anki89 avatar Mar 15 '18 15:03 Anki89

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!

Darahaas avatar Sep 24 '18 15:09 Darahaas

the same error。。。。

Chinenana avatar Jan 07 '19 13:01 Chinenana

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)

Chinenana avatar Jan 07 '19 13:01 Chinenana

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

karmelyoei avatar May 19 '21 20:05 karmelyoei