Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named 'ExceptionNotSeen' #11

Open
ForeverZyh opened this issue Dec 5, 2017 · 14 comments
Open

ImportError: No module named 'ExceptionNotSeen' #11

ForeverZyh opened this issue Dec 5, 2017 · 14 comments

Comments

@ForeverZyh
Copy link

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
Copy link

pmahend1 commented Dec 8, 2017

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
Copy link
Author

Thks!

@peachyDinosaur
Copy link

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
Copy link

pmahend1 commented Dec 18, 2017

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

@peachyDinosaur
Copy link

peachyDinosaur commented Dec 19, 2017

All files already make this import

@pmahend1
Copy link

whats the error message you are getting ? post it here

@iTiPo
Copy link

iTiPo commented Dec 21, 2017

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
Copy link

peachyDinosaur commented Dec 21, 2017

---------------------------------------------------------------------------
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
Copy link

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
Copy link

Anki89 commented Mar 15, 2018

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
Copy link

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!

Neo23x0 added a commit to Neo23x0/naive-bayes-classifier that referenced this issue Nov 1, 2018
@Neo23x0 Neo23x0 mentioned this issue Nov 1, 2018
@Chinenana
Copy link

the same error。。。。

@Chinenana
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants