Python 来自黄昏的恐惧

Python 来自黄昏的恐惧,python,twilio,Python,Twilio,我的代码中有这一行: from twilio.rest import Client 但结果是: Traceback (most recent call last): File "send_sms.py", line 1, in <module> from twilio.rest import Client File "/Users/utilisateur/Downloads/twilio-6.17.0/twilio/rest/__init__.py", line 1

我的代码中有这一行:

from twilio.rest import Client
但结果是:

Traceback (most recent call last):
  File "send_sms.py", line 1, in <module>
    from twilio.rest import Client
  File "/Users/utilisateur/Downloads/twilio-6.17.0/twilio/rest/__init__.py", line 14, in <module>
    from twilio.http.http_client import TwilioHttpClient
  File "/Users/utilisateur/Downloads/twilio-6.17.0/twilio/http/http_client.py", line 1, in <module>
    from requests import Request, Session, hooks
ImportError: No module named requests
回溯(最近一次呼叫最后一次):
文件“send_sms.py”,第1行,在
从twilio.rest导入客户端
文件“/Users/usilisateur/Downloads/twilio-6.17.0/twilio/rest/__init__.py”,第14行,在
从twilio.http.http_客户端导入TwilioHttpClient
文件“/Users/usilisateur/Downloads/twilio-6.17.0/twilio/http/http_client.py”,第1行,在
从请求导入请求、会话、挂钩
ImportError:没有名为请求的模块

我能做什么?

无论您的环境是什么,似乎都没有安装
请求库。运行<代码> PIP,请从该脚本运行的环境中安装请求< /代码>(如果您还没有,您应该考虑使用或类似的方法来避免将Python包安装为root)。

请注意,如果您通过pip安装了Twilio库,那么这种情况可能不会发生,因此我猜您只是下载了它并尝试运行它。如果Python库位于PyPi(which)中,则可以通过pip安装它,并自动安装其依赖项。

无论您的环境是什么,都不会安装
请求
库。运行<代码> PIP,请从该脚本运行的环境中安装请求< /代码>(如果您还没有,您应该考虑使用或类似的方法来避免将Python包安装为root)。

请注意,如果您通过pip安装了Twilio库,那么这种情况可能不会发生,因此我猜您只是下载了它并尝试运行它。如果Python库位于PyPi(which)中,您可以通过pip安装它,并自动安装它的依赖项。

非常感谢