I installed chatterbot in my terminal earlier today using virtual studio code's terminal. I saw that both chatterbot and chatterbot_corpus worked in installation. Then, I made the following python document:
EDIT: Turns out I should define a chatbot variable first.
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.trainers import ListTrainer
conversation = [
"Hello",
"Hi there!",
"How are you doing?",
"I'm doing great.",
"That is good to hear",
"Thank you.",
"You're welcome."
]
bot = ChatBot('Maya')
trainer = ListTrainer(bot)
trainer.train(conversation)
This was my code
it says this however
bot = ChatBot('Maya')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\chatterbot.py", line 34, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\utils.py", line 54, in initialize_class
return Class(*args, **kwargs)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\storage\sql_storage.py", line 22, in __init__
from sqlalchemy import create_engine
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\__init__.py", line 8, in <module>
from . import util as _util # noqa
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\util\__init__.py", line 14, in <module>
from ._collections import coerce_generator_arg # noqa
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\util\_collections.py", line 16, in <module>
from .compat import binary_types
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Does anyone know how to fix this easily?
EDIT: I just updated python using pip install --upgrade ipython in terminal, but it didn't fix the issue
EDIT 2: Well now I tried updating a package using pip install sqlalchemy --upgrade
But now it gives
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\chatterbot.py", line 34, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\utils.py", line 54, in initialize_class
return Class(*args, **kwargs)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\storage\sql_storage.py", line 46, in __init__
if not self.engine.dialect.has_table(self.engine, 'Statement'):
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\dialects\sqlite\base.py", line 2009, in has_table
self._ensure_has_table_connection(connection)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\engine\default.py", line 341, in _ensure_has_table_connection
raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: The argument passed to Dialect.has_table() should be a <class 'sqlalchemy.engine.base.Connection'>,
got <class 'sqlalchemy.engine.base.Engine'>. Additionally, the Dialect.has_table() method is for internal dialect use only; please use ``inspect(some_engine).has_table(<tablename>>)`` for public API use.
I am in the latest version though
PS C:\Users\Subha> Python --version
Python 3.9.6
EDIT 3: Now it comes up with
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\chatterbot.py", line 34, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\utils.py", line 54, in initialize_class
return Class(*args, **kwargs)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chatterbot\storage\sql_storage.py", line 46, in __init__
# if not self.engine.dialect.has_table(self.engine, 'Statement'):
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\dialects\sqlite\base.py", line 2009, in has_table
self._ensure_has_table_connection(connection)
File "C:\Users\Subha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\engine\default.py", line 341, in _ensure_has_table_connection
raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: The argument passed to Dialect.has_table() should be a <class 'sqlalchemy.engine.base.Connection'>, got <class 'sqlalchemy.engine.base.Engine'>. Additionally, the Dialect.has_table() method is for internal dialect use only; please use ``inspect(some_engine).has_table(<tablename>>)`` for public API use.
it seems the python upgrade worked with regard to the initial error on time.clock. This new error you are seeing is quite different to the previous one. In this case you need to go into chatterbot/storage/sql_storage.py and comment out if not self.engine.dialect.has_table(self.engine, 'Statement'): and leave only self.create_database(). This means that instead of checking whether a database table has been created which is triggering the error, it will just create the DB every time, which i expect to work fine.
# if not self.engine.dialect.has_table(self.engine, 'Statement'):
self.create_database()
Related
tried to run docly to auto generate some comments for my python code. installation went smooth:
pip install -U PyYAML
pip install docly
however, when trying to process the first file via:
docly-gen first_file.py
there keeps coming the error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/docly-gen", line 11, in <module>
load_entry_point('docly==0.3.0', 'console_scripts', 'docly-gen')()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/cli/docly_gen.py", line 237, in main
table_rows, docstr_loc, ipynb_files = _process(args, model, tokenizer, ts_lib_path, config)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/halo/halo.py", line 132, in wrapped
return f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/cli/docly_gen.py", line 154, in _process
for code_tokens, params, start_index, function_name, ds in process_file(f_path, ts_lib_path, args.use_old_model):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/ioutils/__init__.py", line 125, in process_file
result, parser_obj = py_parser.parse(file_path, ts_lib_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/parser/parser.py", line 11, in parse
python_parser = PythonParser(library_loc=tslib_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tree_hugger/core/parser/python/python_parser.py", line 35, in __init__
super(PythonParser, self).__init__('python', 'python_queries', PythonParser.QUERY_FILE_PATH, library_loc)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tree_hugger/core/code_parser.py", line 41, in __init__
self.parser.set_language(self.language)
ValueError: Incompatible Language version 11. Must be between 13 and 14
already tried playing around with different versions of tree-sitter
anyone has an idea for a fix?
thanks. much appreciated.
I recently tried to install the spaCy module for Python 3.7. The installation looks like it runs successfully (shows no errors), but when I try to import spaCy, or when I try to install spaCy models, I get the error below. I'm totally lost; please help!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\__init__.py", line 14, in <module>
from . import pipeline # noqa: F401
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\pipeline\__init__.py", line 1, in <module>
from .attributeruler import AttributeRuler
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\pipeline\attributeruler.py", line 6, in <module>
from .pipe import Pipe
File "spacy\pipeline\pipe.pyx", line 1, in init spacy.pipeline.pipe
File "spacy\strings.pyx", line 15, in init spacy.strings
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\util.py", line 1635, in <module>
default_error_handler: Callable[[str, "Pipe", List["Doc"], Exception], NoReturn],
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\typing.py", line 755, in __getitem__
return self.__getitem_inner__(params)
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\typing.py", line 251, in inner
return func(*args, **kwds)
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\typing.py", line 774, in __getitem_inner__
result = _type_check(result, msg)
File "C:\Users\mjrei\AppData\Local\Programs\Python\Python37\lib\typing.py", line 135, in _type_check
raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain typing.NoReturn is not valid as type argument
Im following a tutorial on ML and quandl and have imported quandl and dependencies for python3. When I run
import quandl
data = quandl.get("EIA/PET_RWTC_D")
print(data.head())
I have a quandl account and this code is from the quandl python docs since I wanted to make sure the tutorial was not wrong (https://www.youtube.com/watch?v=JcI5Vnw0b2c&list=PLQVvvaa0QuDfKTOs3Keq_kaG2P55YRn5v&index=2) (I made sure it was lowercase quandl for import since it differed due to the posted date of the video), I also tried with my api_key and using that arg in quandl.get()
I get the error:
Traceback (most recent call last):
File "ml_regression1.py", line 4, in <module>
quandl.get("EIA/PET_RWTC_D", authtoken="MyAuthTokenPlaceHolder")
File "/usr/local/lib/python3.5/dist-packages/quandl/get.py", line 48, in get
data = Dataset(dataset_args['code']).data(params=kwargs, handle_column_not_found=True)
File "/usr/local/lib/python3.5/dist-packages/quandl/model/dataset.py", line 47, in data
return Data.all(**updated_options)
File "/usr/local/lib/python3.5/dist-packages/quandl/operations/list.py", line 14, in all
r = Connection.request('get', path, **options)
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 38, in request
return cls.execute_request(http_verb, abs_url, **options)
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 42, in execute_request
session = cls.get_session()
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 58, in get_session
adapter = HTTPAdapter(max_retries=cls.get_retries())
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 74, in get_retries
raise_on_status=False)
TypeError: __init__() got an unexpected keyword argument 'raise_on_status'
Any help would be great, thank you.
pip3 install --upgrade urllib3 solved the problem for me (urllib3 was not up to date).
see also https://stackoverflow.com/a/53375266/8496767
I have created an exe file using py2exe, however it gives me an Attribute error and an import error on execution. I have used urllib2 and BeautifulSoup in my main script, which is abc.py
Here is my setup.py:
from distutils.core import setup
import py2exe
setup(console=['abc.py'])
options={"py2exe": {'includes': ["BeautifulSoup"]}}
I have added the 'includes' parameter after referring to another question on this website. It however doesn't work for me.
The output I get from abc.exe is
C:\Users\Dhruv Mullick\Desktop\dist>abc.exe Traceback (most recent
call last): File
"C:\Python27\lib\site-packages\py2exe\boot_common.py", line 92, in
import linecache File "linecache.pyc", line 9, in File "os.pyc", line 398, in File "UserDict.pyc", line 83,
in File "_abcoll.pyc", line 11, in File
"abc.pyc", line 3, in File "bs4__init__.pyc", line 30, in
File "bs4\builder__init__.pyc", line 1, in File
"collections.pyc", line 6, in AttributeError: 'module' object
has no attribute 'all' Traceback (most recent call last): File
"abc.py", line 3, in File "bs4__init__.pyc", line 26, in
File "os.pyc", line 398, in File "UserDict.pyc",
line 83, in File "_abcoll.pyc", line 11, in File
"abc.pyc", line 3, in ImportError: cannot import name
BeautifulSoup
C:\Users\Dhruv Mullick\Desktop\dist>
Your script 'abc.py' conflicts with the abc module in Python's standardlibrary.
Rename the script to something else (maybe abc_app.py), adapt the setup-script and rebuild.
You should also make sure to remove any 'abc.pyc' or 'abc.pyo' files which you may have. And remove the 'build' directory that py2exe creates...
If I import pgdb just in command line, it works fine.
It was also working fine in Eclipse until recently (with exactly the same Python 2.7.2), but now, when I import pgdb, even in a very simple file (containing just import pgdb), I have this error message:
Traceback (most recent call last):
File ".../src/pgdbtest.py", line 8, in <module>
import pgdb
File "build/bdist.macosx-10.6-x86_64/egg/pgdb.py", line 66, in <module>
File "build/bdist.macosx-10.6-x86_64/egg/_pg.py", line 7, in <module>
File "build/bdist.macosx-10.6-x86_64/egg/_pg.py", line 4, in __bootstrap__
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 908, in resource_filename
self, resource_name
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1383, in get_resource_filename
self._extract_resource(manager, self._eager_to_zip(name))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1401, in _extract_resource
timestamp = time.mktime(date_time)
AttributeError: 'module' object has no attribute 'mktime'
In fact, more generally, I discovered that if I try from time import mktime, I also have error:
from time import mktime
ImportError: cannot import name mktime
OK, stupid mistake: I created a package named "time"...
So I just deleted it and everything is alright now.