mac上的Python-Twilio安装问题?

问题描述 投票:1回答:3

我正在尝试通过Udacity学习Python,本章的主题是Twilio。我按照建议通过终端安装了Twilio:

Tonys-MacBook-Pro:Versions tonychu$ sudo easy_install twilio
Password:
Searching for twilio
Best match: twilio 6.3.dev0
Processing twilio-6.3.dev0-py2.7.egg
twilio 6.3.dev0 is already the active version in easy-install.pth
Using /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/twilio-6.3.dev0-py2.7.egg
Processing dependencies for twilio
Finished processing dependencies for twilio

结果表明它已成功安装,但是当我尝试通过IDLE导入twilio时,建议不然。无论如何我可以解决这个问题?谢谢。

Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

>>> import twilio
>>> print(twilio.__version__)
6.3.dev0
>>> ================================ RESTART ================================
>>> 

Traceback (most recent call last):
  File "/Users/tonychu/Documents/Programming/Python/send_text.py", line 1, in     <module>
    from twilio.rest import TwilioRestClient
  File "/Users/tonychu/Documents/Programming/Python/twilio.py", line 2, in <module>
    print(twilio.__version__)
AttributeError: 'module' object has no attribute '__version__'
>>> 
python macos twilio
3个回答
0
投票

Twilio开发者传道者在这里。

我建议使用pip安装Twilio如下:

pip install twilio

如果您没有安装pip,可以在终端上运行以下命令:

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

安装Twilio后,您将拥有最新版本的稳定Twilio library,截至撰写本文时为5.4.0。但你可以随时查看最新版本here

如果这有助于您,请告诉我。


0
投票

http://twilio-python.readthedocs.io/en/latest/faq.html告诉我们检查以确保您没有名为twilio.py的文件; Python将尝试从twilio.py文件而不是Twilio库加载Twilio库。


0
投票

你的代码有问题而不是twilio

用这个

from twilio.rest import Client

代替

from twilio.rest import TwilioRestClient
© www.soinside.com 2019 - 2024. All rights reserved.