【问题标题】:Python-Twilio Installation issue on mac?Mac上的Python-Twilio安装问题?
【发布时间】:2016-04-21 12:57:02
【问题描述】:

我正在尝试通过 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


    【解决方案1】:

    这里是 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

    如果这对你有帮助,请告诉我。

    【讨论】:

    • 您好,感谢您的回复。我已经运行了sudo easy_install pipsudo pip install twilio,但运行程序时我仍然面临同样的问题。是否可以通过电子邮件或 Skype 与您联系?
    • 好的,给我发电子邮件到 marcos@twilio.com
    • 我在 MacOS high sierra -bash: wget: command not found 上遇到了这个错误
    • @alsadk 查看此链接,了解如何在 Mac 上获取 wget。 coolestguidesontheplanet.com/install-and-configure-wget-on-os-x
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      你的代码有问题,不是 twilio

      使用这个

      from twilio.rest import Client
      

      代替

      from twilio.rest import TwilioRestClient
      

      【讨论】:

        猜你喜欢
        • 2017-03-18
        • 2023-03-25
        • 2018-01-10
        • 1970-01-01
        • 1970-01-01
        • 2017-03-19
        • 1970-01-01
        • 1970-01-01
        • 2019-01-07
        相关资源
        最近更新 更多