无法在我正在创建的Python聊天机器人中导入随机数

时间:2016-11-02 10:34:28

标签: python

我想在Python中使用telegram api创建一个聊天机器人,但是我收到了一个错误。

以下是我的代码:

import telepot, time

import urllib3

def handle(msg):
    chat_id = msg['chat']['id']
    command = msg['text']
    print 'Got command: %s' % command

    if command == '/hello':
        bot.sendMessage(chat_id, "Hello, how are you?")


bot = telepot.Bot('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
bot.notifyOnMessage(handle)

while 1:
    time.sleep(10)

我得到的错误是:

Traceback (most recent call last):
  File "C:\Users\KUNTALS\workspace\ChatBot\tel_bot4.py", line 1, in <module>
    import telepot, time
  File "C:\Python27\lib\site-packages\telepot\__init__.py", line 259, in <module>
    from . import api
  File "C:\Python27\lib\site-packages\telepot\api.py", line 1, in <module>
    import urllib3
  File "C:\Python27\lib\site-packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "C:\Python27\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "C:\Python27\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
    mod = mod._resolve()
  File "C:\Python27\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "C:\Python27\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
  File "C:\Python27\lib\httplib.py", line 80, in <module>
    import mimetools
  File "C:\Python27\lib\mimetools.py", line 6, in <module>
    import tempfile
  File "C:\Python27\lib\tempfile.py", line 35, in <module>
    from random import Random as _Random
ImportError: cannot import name Random

0 个答案:

没有答案