BUILD CHATBOTS WITH PYTHON- Discover Insights into Classic Texts - python

I keep getting this error code from my Jupyter Notebook and there is little to no explanation.
After inputting:
from nltk import pos_tag, RegexpParser
from tokenize_words import word_sentence_tokenize
from chunk_counters import np_chunk_counter, vp_chunk_counter
I get:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-14-a5041508c9f2> in <module>
1 from nltk import pos_tag, RegexpParser
----> 2 from tokenize_words import word_sentence_tokenize
3 from chunk_counters import np_chunk_counter, vp_chunk_counter
ModuleNotFoundError: No module named 'tokenize_words'
The full lesson allows the student to follow along with Jupyter. I don't know why but all it ever gives me is module not found error codes.

Related

ModuleNotFoundError: No module named 'xagg.wrappers'

I am trying to import a package 'xagg' but it gives me the error described below. I managed to install 'xagg' but the following error popped up when I try to import it
Here is the command line
import xagg as xa
The error I got:
ModuleNotFoundError Traceback (most recent call last)
Input In [15], in <module>
----> 1 import xagg as xa
File ~\AppData\Roaming\Python\Python39\site-packages\xagg\__init__.py:5, in <module>
1 # Eventually restrict to just pixel_overlaps and aggregate; with
2 # everything else happening behind the scenes (and the exporting
3 # happening as methods to the classes that are exported from those
4 # two functions)
----> 5 from .wrappers import pixel_overlaps
6 from .aux import (normalize,fix_ds,get_bnds,subset_find)
7 from .core import aggregate
ModuleNotFoundError: No module named 'xagg.wrappers'
OS: Windows
pip install wrapper
I hope it work

cannot import name 'TfidfVectorizer' from 'sklearn.feature_extraction'

I am trying to do a Topic modeling project, but when I use
from sklearn.feature_extraction import TfidfVectorizer
I will receive this error, my sckit-learn version installed is 0.24.1. I will be grateful if anyone could help me.
ImportError Traceback (most recent call last)
<ipython-input-2-5ae89ed22b7e> in <module>
----> 1 from sklearn.feature_extraction import TfidfVectorizer
ImportError: cannot import name 'TfidfVectorizer' from 'sklearn.feature_extraction' (C:\Users\mozha\Anaconda3\envs\spyder-env\lib\site-packages\sklearn\feature_extraction\__init__.py)
You have to import vectorizers like TfidfVectorizer from sklearn.feature_extraction.text and not sklearn.feature_extraction.

rasa_nlu error while creating small chatbot

Iam getting the below error ModuleNotFoundError: No module named 'rasa_nlu', even though i installed rasa_nlu and rasa
My code :
from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer
def train_nlu(data, config, model_dir):
training_data = load_data(data)
trainer = Trainer(RasaNLUConfig(config))
trainer.train(training_data)
model_directory = trainer.persist(model_dir, fixed_model_name='weathernlu')
if __name__ == '__main__':
train_nlu('.data/data.json', 'config_spacy.json', './models/nlu')
Error message:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-6ab2834ad68f> in <module>()
----> 1 from rasa_nlu.training_data import load_data
2 #from rasa_nlu.converters import load_data
3 from rasa_nlu.config import RasaNLUConfig
4 from rasa_nlu.model import Trainer
5
ModuleNotFoundError: No module named 'rasa_nlu'
Someone please help me
In Rasa >= 1.0, there is no separate installation of NLU. It's just rasa, and then in code you'd access rasa.nlu. Make sure you're looking at the latest version of the docs and have installed the latest version of rasa - https://rasa.com/docs/rasa/user-guide/installation/

NameError: name 'the_given_file' is not defined while being in the directory

I try to import a file Python which is in the same folder with the jupyter notebook I'm calling it. It worked well until some point when I shut down the kernel and relaunched it :
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-7-28aefea88e42> in <module>
1 import imp
2 from stocker import Stocker
----> 3 imp.reload(stocker)
NameError: name 'stocker' is not defined
I also tried with importlib :
import importlib
from stocker import Stocker
importlib.reload(stocker)
But it didn't worked neither.
Thus I thought it was a Path problem so I added it with sys.path.append(r'C:\Users\antoi\Documents\Programming\Luxurynsight\Finance')
C:\ProgramData\Anaconda3\python36.zip
C:\ProgramData\Anaconda3\DLLs
C:\ProgramData\Anaconda3\lib
C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\lib\site-packages
C:\ProgramData\Anaconda3\lib\site-packages\win32
C:\ProgramData\Anaconda3\lib\site-packages\win32\lib
C:\ProgramData\Anaconda3\lib\site-packages\Pythonwin
C:\ProgramData\Anaconda3\lib\site-packages\IPython\extensions
C:\Users\antoi\.ipython
C:\Users\antoi\AppData\Local\Temp\tmpxi5uysfy
C:\Users\antoi\AppData\Local\Temp\tmpvwwnclc1
C:\Users\antoi\Documents\Programming\Luxurynsight\Finance
C:\Users\antoi\Documents\Programming\Luxurynsight\Finance
C:\Users\antoi\Documents\Programming\Luxurynsight\Finance
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-15-0bf8ff56cd18> in <module>
6 import importlib
7 from stocker import Stocker
----> 8 importlib.reload(stocker)
9
10 import imp
NameError: name 'stocker' is not defined
But it doesn't work ...
I also tried from the anaconda prompt and it is the same error. My OS is Windows10.
Update
I tried to get rid of imp.reload(). Now I import the file stocker.py with from stocker import Stocker. Yet, how can I load the former library then ?

ImportError in Jupyter Notebook

I am trying import a module in Jupyter and it is not working:
import alyn
ImportError Traceback (most recent call last)
<ipython-input-8-8e9535ea4303> in <module>()
----> 1 import alyn
~\Anaconda3\envs\tracx\lib\site-packages\alyn\__init__.py in <module>()
1 """ Import required modules"""
----> 2 from deskew import *
3 from skew_detect import *
ImportError: No module named 'deskew'
I don't quite understand why, since the package in question has a correct init.py file:
whose contents are:
""" Import required modules"""
from deskew import *
from skew_detect import *
What am I missing?
P.S.
This is all taking place on Windows 10.
Well, I've figured it out!
Turns out that the package I was trying to import is written in Python 2 and its init file is using the relative import mechanism. However, I am working in Python 3 and relative import is no longer supported in it. The init file can be made to work in Python 3 by adding a . in both lines, like this:
""" Import required modules"""
from .deskew import *
from .skew_detect import *
I think this should be backward compatible with Python 2.

Categories