Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何运行twilio程序?_Python_Python 2.7_Twilio - Fatal编程技术网

Python 如何运行twilio程序?

Python 如何运行twilio程序?,python,python-2.7,twilio,Python,Python 2.7,Twilio,我正在运行此代码,该代码给出错误: from twilio.rest import TwilioRestClient account_sid="AC9d3b9e6da765********************" auth_token="5c6ff9b2e2dc********************" client= TwilioRestClient(account_sid , auth_token) message = client.sms.message.create( bod

我正在运行此代码,该代码给出错误:

from twilio.rest import TwilioRestClient

account_sid="AC9d3b9e6da765********************"
auth_token="5c6ff9b2e2dc********************"
client= TwilioRestClient(account_sid , auth_token)
message = client.sms.message.create(
    body="This is Deadshot",
    to="+919582******",
    from_="+91987*******")

print message.sid
运行时,会出现以下错误:

Traceback (most recent call last):
  File "C:\Python27\myFiles\twilio_demo.py", line 4, in <module>
    from twilio.rest import TwilioRestClient
  File "C:\Python27\lib\site-packages\twilio-6.3.0-py2.7.egg\twilio\rest\__init__.py", line 12, in <module>
    from twilio.base.exceptions import TwilioException
  File "C:\Python27\lib\site-packages\twilio-6.3.0-py2.7.egg\twilio\base\exceptions.py", line 4, in <module>
    from six import u
ImportError: No module named six
回溯(最近一次呼叫最后一次):
文件“C:\Python27\myFiles\twilio\u demo.py”,第4行,在
从twilio.rest导入TwilioRestClient
文件“C:\Python27\lib\site packages\twilio-6.3.0-py2.7.egg\twilio\rest\ \uuuuu init\uuuuu.py”,第12行,在
从twilio.base.exceptions导入TwilioException
文件“C:\Python27\lib\site packages\twilio-6.3.0-py2.7.egg\twilio\base\exceptions.py”,第4行,在
从六个进口美国
ImportError:没有名为six的模块
然后运行代码

尝试将twillio升级到最新版本,并使用以下代码

    from twilio.rest import Client
    account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    auth_token  = "your_auth_token"

    client = Client(account_sid, auth_token)

    message = client.messages.create(
        to="", 
        from_="",
        body="Hello from Python!")

print(message.sid)
然后运行代码

尝试将twillio升级到最新版本,并使用以下代码

    from twilio.rest import Client
    account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    auth_token  = "your_auth_token"

    client = Client(account_sid, auth_token)

    message = client.messages.create(
        to="", 
        from_="",
        body="Hello from Python!")

print(message.sid)

在哪里写这个@如果您使用的是ubuntu/mac或cmd,如果您使用的是windows,请在终端中执行Exprator。如果您使用的是ubuntu/mac,请不要忘记在开始时添加sudo。现在,在最后一行中出现了一个错误,上面写着:from requests import Request,Session importorror:没有名为requests的模块@解释原始代码中需要的任何更改@exprator不只是从终端安装库,然后运行程序在哪里编写@如果您使用的是ubuntu/mac或cmd,如果您使用的是windows,请在终端中执行Exprator。如果您使用的是ubuntu/mac,请不要忘记在开始时添加sudo。现在,在最后一行中出现了一个错误,上面写着:from requests import Request,Session importorror:没有名为requests的模块@解释原始代码中需要的任何更改@exprator只需从终端安装库,然后运行程序