orlnub123 / cleverbot.py

A Cleverbot API wrapper for Python with asynchronous functionality.
MIT License
2 stars 1 forks source link

AttributeError: module 'cleverbot' has no attribute 'Cleverbot' #1

Closed MattBSG closed 7 years ago

MattBSG commented 7 years ago

Installed cleverbot.py through pip today and when defining variable cb, I get an Attribute error.

import cleverbot
cb = cleverbot.Cleverbot('TOKEN', timeout=15)

This was being used for a discord bot. The stacktrace is as follows: Traceback (most recent call last): File "cleverbot.py", line 5, in import cleverbot File "/root/cleverbot/cleverbot.py", line 9, in cb = cleverbot.Cleverbot('REDACTED', timeout=15) AttributeError: module 'cleverbot' has no attribute 'Cleverbot'

orlnub123 commented 7 years ago

When importing Python first searches for the module in the current directory, which it found as your module's name is cleverbot. So instead of importing the cleverbot in site-packages it imported itself.

Changing your module's name will fix it.