问题描述
关于此 twilio-python ,我遇到了与该线程相同的问题:
I am having the same problem as this thread regarding twilio-python:
twilio.rest从twilio python中丢失模块版本2.0.8?
但是我有同样的问题,但是我安装了3.3.3.尝试导入twilio.rest时,仍然出现没有名为rest的模块"的信息.
However I have the same problem but I have 3.3.3 installed. I still get "No module named rest" when trying to import twilio.rest.
从独立的python脚本加载库.因此,我知道安装软件包的pip可以正常工作.
Loading the library from stand alone python script works. So I know that pip installing the package worked.
from twilio.rest import TwilioRestClient
def main():
account = "xxxxxxxxxxxxxxxx"
token = "xxxxxxxxxxxxxxxx"
client = TwilioRestClient(account, token)
call = client.calls.create(to="+12223344",
from_="+12223344",
url="http://ironblanket.herokuapp.com/",
method="GET")
if __name__ == "__main__":
main()
但这不起作用:
from twilio.rest import TwilioRestClient
def home(request):
client = TwilioRestClient(account, token)
您知道我接下来可以尝试什么吗?
Do you have any idea what I can try next?
推荐答案
我在项目twilio.py
中命名了一个python文件.由于该文件是首先加载的,因此随后的加载twilio的调用将引用该文件而不是twilio库.
I named a python file in my project twilio.py
. Since that file was loaded first, then subsequent calls to load twilio would reference that file instead of the twilio library.
TLDR:只是不要将您的python文件命名为twilio.py
这篇关于twilio中的导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!