I am trying to create a chatbot, but since latest version of chatterbot was not getting installed on my pc so I installed chatterbot by using pip install chatterbot==1.0.4 and the following error is showing up.
How do I resolve this?
Below is the code:
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
bot = ChatBot("My Bot")
convo = [
'hello',
'hi there',
'what is your name?',
'My name is BOT, I am created my a hooman ',
'how are you',
'i am doing great these days',
'thank you',
'in which city you live',
'i live in kalyan',
'in which languages do you speak',
'i mostly talk in english'
]
trainer=ListTrainer(bot)
trainer.train(convo)
print("Talk to Bot")
while True:
query=input()
if query=='exit':
break
answer=bot.get_response
print("bot : ", answer)
output :
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS E:\GIT VS CODE\Py> & D:/Python/python.exe "e:/GIT VS CODE/Py/chatbot.py"
Traceback (most recent call last):
File "e:\GIT VS CODE\Py\chatbot.py", line 4, in <module>
bot = ChatBot("My Bot")
File "D:\Python\lib\site-packages\chatterbot\chatterbot.py", line 34, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "D:\Python\lib\site-packages\chatterbot\utils.py", line 54, in initialize_class
return Class(*args, **kwargs)
File "D:\Python\lib\site-packages\chatterbot\storage\sql_storage.py", line 22, in __init__
from sqlalchemy import create_engine
File "D:\Python\lib\site-packages\sqlalchemy\__init__.py", line 8, in <module>
from . import util as _util # noqa
File "D:\Python\lib\site-packages\sqlalchemy\util\__init__.py", line 14, in <module>
from ._collections import coerce_generator_arg # noqa
File "D:\Python\lib\site-packages\sqlalchemy\util\_collections.py", line 16, in <module>
from .compat import binary_types
File "D:\Python\lib\site-packages\sqlalchemy\util\compat.py", line 264, in <module> time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
I agree with #Glycerine's answer, well, if you don't want to downgrade your python version, I have another solution for you.
Open the file <Python-folder>\Lib\site-packages\sqlalchemy\util\compat.py
Go to line 264 which states:
if win32 or jython:
time_func = time.clock
else:
time_func = time.time
Change it to:
if win32 or jython:
#time_func = time.clock
pass
else:
time_func = time.time
Simply here we are avoiding the use of timer.clock method and the time_func object because I saw that this object is just created for nothing and does nothing. It is just created and left untouched.
I don't know why even this exists when it is of no use. But this should work for you.
Hope it helped!
What version of python are you running? time.clock has been removed for py 3.8+
Solutions include downgrading python or altering the source it seems:
AttributeError: module 'time' has no attribute 'clock' in Python 3.8
From the Python 3.8 doc:
The function time.clock() has been removed, after having been deprecated since Python 3.3: use time.perf_counter() or time.process_time() instead, depending on your requirements, to have well-defined behavior. (Contributed by Matthias Bussonnier in bpo-36895.)
Solution for - AttributeError: module 'time' has no attribute 'clock'
In Response to your comment: I'm assuming the chatterbox devs will fix this eventually but yes, downgrading to Python 3.7 will fix this: https://docs.python.org/3.7/library/time.html#time.clock
Deprecated since version 3.3, will be removed in version 3.8: The behaviour of this function depends on the platform: use perf_counter() or process_time() instead, depending on your requirements, to have a well defined behaviour.
Im not an expert, but have you tried 'import time' in the top of your code. Worked for me when I was using time.sleep() in my pythoncode
Related
I'm running Python 3.8.3
From the following code, from tcms_api import TCMS throws an error.
from tcms_api import TCMS
rpc_client = TCMS()
test_case = rpc_client.TestCase.create({
'summary': 'My testing',
'product': 2,
'category': 2,
'priority': 1,
'is_automated': True,
'text': 'my first test case',
'case_status': 2, # CONFIRMED
})
Error:
Traceback (most recent call last):
File "C:/Users/bokro/PycharmProjects/tcms/Test.py", line 1, in <module>
from tcms_api import TCMS
File "C:\Users\bokro\AppData\Local\Programs\Python\Python38\lib\site-packages\tcms_api\__init__.py", line 81, in <module>
from tcms_api.xmlrpc import TCMSXmlrpc, TCMSKerbXmlrpc
File "C:\Users\bokro\AppData\Local\Programs\Python\Python38\lib\site-packages\tcms_api\xmlrpc.py", line 130, in <module>
class TCMSKerbXmlrpc(TCMSXmlrpc):
File "C:\Users\bokro\AppData\Local\Programs\Python\Python38\lib\site-packages\tcms_api\xmlrpc.py", line 137, in TCMSKerbXmlrpc
transport = KerbTransport()
File "C:\Users\bokro\AppData\Local\Programs\Python\Python38\lib\xmlrpc\client.py", line 1351, in __init__
super().__init__(use_datetime=use_datetime,
TypeError: __init__() got an unexpected keyword argument 'headers'
Process finished with exit code 1
I have endlessly looked everywhere online and haven't been able to find anybody with the same issue. I am wondering if anybody has experienced this problem or knows how to solve it. Any help with this would be greatly appreciated.
SOLUTION: For anybody experiencing the same issue, I have solved it by downgrading to Python 3.6. The API does not seem to be compatible with 3.8. Hope this helped someone.
SOLUTION: For anybody experiencing the same issue, I have solved it by
downgrading to Python 3.6. The API does not seem to be compatible with
3.8. Hope this helped someone.
Glad to see you were able to resolve this. In particular the transport classes, KerbTransport() as it seems in your case, inherit from standard networking transport classes in Python which change from version to version.
tcms-api is currently developed and tested only on Python 3.6.
I'm attempting to start working with building chat bot within python. I would really want to start programming one from scratch. I'm starting with the ChatterBot module to learn how it works. I have pip installed all modules but I'm still having trouble with 'ChatterBotCorpusTrainer'Im getting a missing error. I run python 3.7 and I have the updated ChatBot module.
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
bot= ChatBot('Bot')
trainer = ChatterBotCorpusTrainer(bot)
corpus_path = '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chatterbot_corpus/data/english'
for file in os.listdir(corpus_path):
trainer.train(corpus_path + file)
conversation = [
"Hello",
"Hi there!",
"How are you doing?",
"I'm doing great.",
"That is good to hear",
"Thank you.",
"You're welcome."
]
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train('chatterbot.corpus.english')
response = chatbot.get_response("Good morning!")
print(response)
this is the error I'm getting
/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot/storage/jsonfile.py:26: UnsuitableForProductionWarning: The JsonFileStorageAdapter is not recommended for production environments.
self.UnsuitableForProductionWarning
Traceback (most recent call last):
File "/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/chat_1_1.py", line 6, in <module>
trainer = ChatterBotCorpusTrainer(bot)
File "/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot/trainers.py", line 101, in __init__
from .corpus import Corpus
File "/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot/corpus/__init__.py", line 6, in <module>
from chatterbot_corpus import Corpus
ImportError: cannot import name 'Corpus' from 'chatterbot_corpus' (/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot_corpus/__init__.py)
You need to specify the module (chatterbot.trainers). You have 2 options:
1
from chatterbot import trainers
2
trainer = chatterbot.trainers.ChatterBotCorpusTrainer
still rather new to Python. I've been referencing a few blogs regarding the jnpr.junos packages. Specifically from Jeremy Schulman (http://forums.juniper.net/t5/Automation/Python-for-Non-Programmers-Part-2/bc-p/277682). I'm simply trying to make sure I have the commands right. I'm just attempting to pass simple commands to my SRX cluster. I'm attempting to pass the following to an SRX650 cluster.
>>> from jnpr.junos.utils.config import Config
>>> from jnpr.junos import Device
>>> dev = Device(host='devip',user='myuser',password='mypwd')
>>> dev.open()
Device(devip)
>>> cu = Config(dev)
>>> cu
jnpr.junos.utils.Config(devip)
>>> set_cmd = 'set system login message "Hello Admin!"'
>>> cu.load(set_cmd,format='set')
Warning (from warnings module):
File "C:\Python27\lib\site-packages\junos_eznc-1.0.0- py2.7.egg\jnpr\junos\utils\config.py", line 273
if any([e.find('[error-severity="error"]') for e in rerrs]):
FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
cu.load(set_cmd,format='set')
File "C:\Python27\lib\site-packages\junos_eznc-1.0.0- py2.7.egg\jnpr\junos\utils\config.py", line 296, in load
return try_load(rpc_contents, rpc_xattrs)
File "C:\Python27\lib\site-packages\junos_eznc-1.0.0-py2.7.egg\jnpr\junos\utils\config.py", line 274, in try_load
raise err
RpcError
I've done quite a bit of searching and can't seem to find anything as to why this RPC error is popping up. I've confirmed that the syntax is correct and read through the jnpr.junos documentation for Junos EZ.
Found that I was using an outdated version of junos.eznc. Running pip install -U junos-eznc updated me to junos.eznc 1.3.1. After doing this, my script worked properly.
I am working on creating a WebGL interface for which I am trying to convert FBX models to JSON file format in an automated process using python file, convert_fbx_three.py (from Mr. Doob's GitHub project) from command line.
When I try the following command to convert the FBX:
python convert_fbx_three.py Dolpine.fbx Dolpine
I get following errors:
Error in cmd:
Traceback (most recent call last):
File "convert_fbx_three.py", line 1625, in <module>
sdkManager, scene = InitializeSdkObjects()
File "D:\xampp\htdocs\upload\user\fbx\FbxCommon.py", line 7, in InitializeSdkObjects
lSdkManager = KFbxSdkManager.Create()
NameError: global name 'FbxManager' is not defined
I am using Autodesk FBX SDK 2012.2 available here on Windows 7.
Can you please try the following:
import FbxCommon
.
.
.
lSdkManager, lScene = FbxCommon.InitializeSdkObjects()
You probably need to add environment variables pointing to the folder that contains fbx.pyd, FbxCommon.py, and fbxsip.pyd prior to calling anything in those modules.
Are there any libraries in Python that does or allows Text To Speech Conversion using Mac Lion's built in text to speech engine?
I did google but most are windows based. I tried pyttx.
I tried to run
import pyttsx
engine = pyttsx.init()
engine.say('Sally sells seashells by the seashore.')
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
But I get these errors
File "/Users/manabchetia/Documents/Codes/Speech.py", line 2, in <module>
engine = pyttsx.init()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/__init__.py", line 39, in init
eng = Engine(driverName, debug)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/engine.py", line 45, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/driver.py", line 64, in __init__
self._module = __import__(name, globals(), locals(), [driverName])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyttsx-1.0.egg/pyttsx/drivers/nsss.py", line 18, in <module>
ImportError: No module named Foundation
How do I solve these errors?
Wouldn't it be much simpler to do this?
from os import system
system('say Hello world!')
You can enter man say to see other things you can do with the say command.
However, if you want some more advanced features, importing AppKit would also be a possibility, although some Cocoa/Objective C knowledge is needed.
from AppKit import NSSpeechSynthesizer
speechSynthesizer = NSSpeechSynthesizer.alloc().initWithVoice_("com.apple.speech.synthesis.voice.Bruce")
speechSynthesizer.startSpeakingString_('Hi! Nice to meet you!')
If you would like to see more things you can do with NSSpeechSynthesizer take a look at Apple's documentation: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSpeechSynthesizer_Class/Reference/Reference.html
If you are targeting Mac OS X as your platform - PyObjC and NSSpeechSynthesizer is your best bet.
Here is a quick example for you
#!/usr/bin/env python
from AppKit import NSSpeechSynthesizer
import time
import sys
if len(sys.argv) < 2:
text = raw_input('type text to speak> ')
else:
text = sys.argv[1]
nssp = NSSpeechSynthesizer
ve = nssp.alloc().init()
for voice in nssp.availableVoices():
ve.setVoice_(voice)
print voice
ve.startSpeakingString_(text)
while not ve.isSpeaking():
time.sleep(0.1)
while ve.isSpeaking():
time.sleep(0.1)
Please note that AppKit module is part of PyObjC bridge and should be already installed on your Mac. No need to install it if you are using OS provided python (/usr/bin/python)
This might work:
import subprocess
subprocess.call(["say","Hello World! (MESSAGE)"])