python app.py
Traceback (most recent call last):
File "app.py", line 1, in <module>
from chatbot import chatbot
File "C:\Users\hp\Desktop\try_projects\chat_bot\chatbot.py", line 1, in <module>
from chatterbot import ChatBot
ModuleNotFoundError: No module named 'chatterbot'
Code is
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer, ChatterBotCorpusTrainer
chatbot= ChatBot('Crazy')
what might be the solution to this problem?
python version: 3.8.3
Try installing the previous version of ChatterBot.
pip install chatterbot==1.0.4
This should work, unless there are some other problems. I had the same problem and it worked for me.
There would be another problem if you are using Python 3.8.x . In Python 3.8.x, a few functions of a few modules were removed.
You will be able to import ChattberBot , but when you name the bot, there will be an error.
File "C:\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Copy the location for the file given in the last line, where the error occurs.
C:\Python38\lib\site-packages\sqlalchemy\util\compat.py
Open file with IDLE or whatever editor you have. Please do Not open the file directly(this will run the file, and you will not be able to see the code) , instead Open with IDLE or Your Text editor
Then , go to line 264 in that . It would be written
time_func = time.clock
Instead of this change it to
time_func = time.perf_counter()
I Hope this helped! This was my first answer on StackOverflow !
Related
I have installed Python Arcade using
pip install arcade
which ran successfully.
When trying to run the example code, or even just trying to import arcade from the Python command line, I receive an error
>>> import arcade
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/brian/.local/lib/python3.8/site-packages/arcade/__init__.py", line 250, in <module>
from .joysticks import get_game_controllers
File "/home/brian/.local/lib/python3.8/site-packages/arcade/joysticks.py", line 1, in <module>
import pyglet.input
File "/home/brian/.local/lib/python3.8/site-packages/pyglet/input/__init__.py", line 179, in <module>
from .evdev import get_devices as evdev_get_devices
File "/home/brian/.local/lib/python3.8/site-packages/pyglet/input/evdev.py", line 509, in <module>
class EvdevControllerManager(ControllerManager, XlibSelectDevice):
File "/home/brian/.local/lib/python3.8/site-packages/pyglet/input/evdev.py", line 583, in EvdevControllerManager
def get_controllers(self) -> list[Controller]:
TypeError: 'type' object is not subscriptable
>>>
Python version is 3.8.10, and OS is Ubuntu 20.04, but I can't get past this error.
This is a known bug in the pyglet library: https://github.com/pyglet/pyglet/issues/614
The code uses list[Controller] which requires Python 3.9 (see PEP 585).
The line was introduced to pyglet in commit 3c2c7de and was fixed in commit 63341c4 (10 days ago as of today), which changes it to List[Controller] (where List is imported from the standard typing module).
Based on the response from #mkrieger1, and the error being shown, I took the following steps:
vim /home/brian/.local/lib/python3.8/site-packages/pyglet/input/evdev.py
added a line below the other import sections at the top
import typing
then went to line 583 (now 584 due to adding above), and changed
def get_controllers(self) -> list[Controller]:
to
def get_controllers(self) -> typing.List[Controller]:
and the example programs are now working.
If anyone else is in the same situation, then hopefully this is a quick fix to try.
I have spent the last hour trying to fix the pandas import error, but with no success.
Python version: 3.8.3
Pandas version: 1.0.4
I use Visual Studio code. Importing other modules works (tried with numpy). Pandas is installed using pip.
The error:
Traceback (most recent call last):
File "c:/Users/38599/Desktop/course1/moduli.py", line 34, in <module>
import pandas
File "C:\Program Files (x86)\Python38-32\lib\site-packages\pandas\__init__.py", line 180, in <module>
import pandas.testing
File "C:\Program Files (x86)\Python38-32\lib\site-packages\pandas\testing.py", line 5, in <module>
from pandas._testing import (
File "C:\Program Files (x86)\Python38-32\lib\site-packages\pandas\_testing.py", line 404, in <module>
RANDS_CHARS = np.array(list(string.ascii_letters + string.digits), dtype=(np.str_, 1))
AttributeError: module 'string' has no attribute 'ascii_letters'
I've tried downgrading pandas and reinstalling it, but nothing fixed the error for me.
Does anyone have any ideas?
remove the line with string.ascii_letters from the code.. as the error says
I faced same issue. I did the following and it worked.
select the py file you want to execute, for vs code menu select Run=>Start Debugging, it works perfectly. I think it is a bug in the current vs code
Do you have a file named string.py somewhere in your workspace, by chance?
If yes, that would be the problem. By Python rules, such a file is also a module named string, so whenever anything is trying to import string, your file gets loaded instead of the standard library module with the same name.
This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 4 years ago.
I am new to python programming and started trying to fool around with flask this morning. I installed flask using pip and it seemed to work as expected. However, when I went to the python shell and typed import flask I got the following error:
>>> import flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/flask/__init__.py", line 17,
in <module>
from werkzeug.exceptions import abort
File "/usr/lib/python2.7/dist-packages/werkzeug/__init__.py", line
151, in <module>
__import__('werkzeug.exceptions')
File "/usr/lib/python2.7/dist-packages/werkzeug/exceptions.py", line
71, in <module>
from werkzeug.wrappers import Response
File "/usr/lib/python2.7/dist-packages/werkzeug/wrappers.py", line
27, in <module>
from werkzeug.http import HTTP_STATUS_CODES, \
File "/usr/lib/python2.7/dist-packages/werkzeug/http.py", line 23,
in <module>
from email.utils import parsedate_tz
File "/usr/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "random.py", line 6, in <module>
print(random.randint(1, 101))
AttributeError: 'module' object has no attribute 'randint''
I uninstalled flask using pip and tried again. No change. I installed flask using apt, same problem I even tried it on python 2, same error message. the really weird part is that it is giving me errors from a python3 shell session I did earlier in the week - the import random for random.py part of the message at the very end. Why would it spit out messages that have nothing to do with the import flask message?
It made me think that maybe I should see if a reboot would help, but no luck there either.
How does one troubleshoot an issue like this? googling the error hasn't helped and I am running out of ideas.
Thanks in advance
From what it looks like the error message you are receiving means you have a file name random.py being invoked. This can happen if the file is in the same folder you are running the command python2 or python3.
According to the error message:
print(random.randint(1, 101))
AttributeError: 'module' object has> no attribute 'randint''
It's trying to load that file. Rename your file to something else and it should work.
If you locate random.py in linux you will see it here (depending on your versions):
/usr/lib/python2.7/random.py
and
/usr/lib/python3.6/random.py
So, your random.py is causing the python command to override the base python random.py file
Im trying to figured out this problem. Yesterday I installed PyScripter and since then, scripts doesnt work. When I run any script (in PyScripter or IDLE) and trying to "import arcpy", it gets this error:
import arcpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\Python26\ArcGIS10.0\lib\arcgisscripting.py", line 81, in <module>
from RuntimeError import RuntimeError
ImportError: No module named RuntimeError
Have somebody any suggestion how to fix it?
Thanks to all very much!
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
(If this doesn't display an error, check that python is added to your system path or if it is even installed at all. But if you've used Python on said machine maybe system path issue)
enter the commmand help('modules')
review the list of modules that's returned to see whether arcpy is included
if not, then you may have to reinstall the module
im new to python gasp .
im wondering do i need extra add-on module for python so it could work? like a module file or something.
my code that i was just trying to see whether it works:
from gasp import*
begin_graphics(800,600,"My Game",color.YELLOW)
end_graphics()
and it gave me this error:
Traceback (most recent call last):
File "C:\Python32\testing idle codes\GASP", line 1, in <module>
from gasp import*
ImportError: No module named gasp
if is a file that needed to download. please guide me. im using window 7 32bit .
Please see http://dev.laptop.org/pub/gasp/downloads/ for what to get for your platform.