2016-10-14 12 views
0

私はこのように始まるコードを実行しようとしています。名前 "irc"をインポートできません

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 

これを実行しようとすると、まずこのトレースバックが発生します。

Traceback (most recent call last): 
    File "bot.py", line 1, in <module> 
    from twisted.words.protocols import irc 
ImportError: cannot import name 'irc' 

~/Desktop/TriviaBot/triviabot(branch:develop*) » pip list            [email protected] 
-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) 

(他の人が何の問題もなく、コードを実行することができます)しかし、私はピップを通じてツイストやIRCの両方をインストールして、これは私だけに起こっているこれは私が」とは何ですかインポートしようとしています。 https://twistedmatrix.com/documents/15.4.0/api/twisted.words.protocols.irc.html

これは適切なバージョンのPythonを使用しています。私は何が起こっているのかは分かりません。

答えて

1

万が一、Python 3を使用していますか? jabberモジュールのみがtwisted.words.protocolsパッケージからPython 3に移植されたようです。 TwistedはPython 2で完全にサポートされていますので、python2を使ってスクリプトを実行してみてください。

+0

はい、私はPython3を使用していました。これを指摘してくれてありがとう。 – Kurolox

関連する問題