我希望使用Python中的Twilio运行以下命令:
ngrok_cmd = "twilio phone-numbers:update "+ my_number " --sms url=https://localhost:5000"
os.system(ngrok_cmd)该命令在终端上工作,但如果我试图通过python执行它,则不会工作。它不断地给出以下错误:
sh: 1: twilio: not found编辑
我试过这个:
ngrok_cmd = "/home/pi/.config/nvm/versions/node/v16.13.1/bin/twilio phone-numbers:update "+ my_number " --sms url=http://localhost:5000"
os.system(ngrok_cmd)现在我得到了这个错误:
» Could not find profile.
» To create the profile, run:
twilio profiles:create
Alternatively, twilio-cli can use credentials stored in environment variables:
# OPTION 1 (recommended)
export TWILIO_ACCOUNT_SID=your Account SID from twil.io/console
export TWILIO_API_KEY=an API Key created at twil.io/get-api-key
export TWILIO_API_SECRET=the secret for the API Key
# OPTION 2
export TWILIO_ACCOUNT_SID=your Account SID from twil.io/console
export TWILIO_AUTH_TOKEN=your Auth Token from twil.io/console
Once these environment variables are set, a twilio-cli profile is not required and you may skip the "login" step.但是,我已经在/etc/profile中设置了环境变量,并通过以下方法验证了它:
printenv | grep TWI我不知道这个错误的原因是什么。有人能帮我吗?
发布于 2021-12-11 10:28:23
错误消息意味着您的shell找不到twilio命令。这是因为当您在终端中运行它时,它所查找的位置与它所看到的位置不同,因为路径(shell查找命令的位置)设置不一样。
您需要进入您的正常终端,在那里twilio工作并运行:
which twilio # or alternatively
type twilio这将告诉您twilio命令的位置,即到达它的完整路径。
在Python代码中使用相同的完整路径,以便它能够找到它。
https://stackoverflow.com/questions/70286462
复制相似问题