I'm trying to run a piece of code that starts like this.
from twisted.words.protocols import irc
from twisted.internet import reactor, protocol
import logging
import logging.config
import utilities
import time
class TriviaBot(irc.IRCClient):
"""A trivia IRC Bot."""
class Event:
"""Events are channel specific commands without arguments that are deactivated if they are triggered once."""
def __init__(self, trigger, channel, callback):
self.trigger = trigger
self.callback = callback
self.channel = channel
The first thing I get when I try to run it is this traceback.
Traceback (most recent call last):
File "bot.py", line 1, in <module>
from twisted.words.protocols import irc
ImportError: cannot import name 'irc'
However, I've installed both Twisted and IRC through pip, and this is only happening to me (other people can run the code without any problem)
~/Desktop/TriviaBot/triviabot(branch:develop*) » pip list kuro@Horus
-lxc (0.1)
aiohttp (0.21.6)
appdirs (1.4.0)
Beaker (1.8.0)
beautifulsoup4 (4.5.1)
Brlapi (0.6.5)
bs4 (0.0.1)
cffi (1.7.0)
chardet (2.3.0)
clipboard (0.0.4)
Cython (0.24.1)
decorator (4.0.10)
discord.py (0.11.0)
flake8 (2.5.4)
flake8-docstrings (0.2.6)
Flask (0.10.1)
i3-py (0.6.4)
inflect (0.2.5)
irc (15.0.3)
itsdangerous (0.24)
jaraco.classes (1.4)
jaraco.collections (1.5)
jaraco.functools (1.15.1)
jaraco.itertools (2.0)
jaraco.logging (1.5)
jaraco.stream (1.1.1)
jaraco.text (1.8)
Jinja2 (2.8)
kazam (1.4.5)
Kivy (1.9.1)
Kivy-Garden (0.1.4)
libusb1 (1.5.0)
livestreamer (1.12.2)
louis (3.0.0)
Mako (1.0.4)
MarkupSafe (0.23)
mccabe (0.4.0)
more-itertools (2.2)
notify2 (0.3)
numpy (1.11.2)
packaging (16.7)
pep257 (0.7.0)
pep8 (1.7.0)
Pillow (3.4.1)
pip (8.1.2)
Pmw (2.0.1)
praw (3.5.0)
py2exe (0.9.2.2)
PyAutoGUI (0.9.33)
pycparser (2.14)
pyflakes (1.0.0)
pygame (1.9.2b8)
Pygments (2.1.3)
pygobject (3.22.0)
PyInstaller (3.2)
PyMsgBox (1.0.3)
PyNaCl (1.0.1)
pyparsing (2.1.10)
pyperclip (1.5.27)
PyScreeze (0.1.8)
pyserial (3.1.1)
python-distutils-extra (2.39)
python-sane (2.8.2)
python-steamcontroller (1.0)
python-xlib (0.17)
PyTweening (1.0.3)
pytz (2016.7)
pyusb (1.0.0)
pyxdg (0.25)
requests (2.10.0)
setproctitle (1.1.10)
setuptools (28.3.0)
six (1.10.0)
tempora (1.6.1)
Twisted (16.4.1)
udemy-dl (0.1.8)
update-checker (0.11)
urllib3 (1.18)
websockets (3.1)
Werkzeug (0.11.10)
wget (3.2)
xerox (0.4.1)
zope.interface (4.3.2)
This is what I'm trying to import. https://twistedmatrix.com/documents/15.4.0/api/twisted.words.protocols.irc.html
It's using the right version of python. I'm not sure what could be happening.
Are you using Python 3 by any chance? It looks like only the jabber
module has been ported to Python 3 from the twisted.words.protocols
package. Twisted is fully supported on Python 2 so try running your script using python2
.