Unknown
Unknown

Reputation: 79

Python Twilio SMS

I have the following code:

from twilio.rest import Client
import os


account_sid = os.environ["TWILIO_ACCOUT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]

client = Client(account_sid, auth_token)

client.messages.create(
    to = "0743157169",
    from_= "0743157169",
    body="Messaj"
)

Pycharm recognise twilio library(or package) and when I write some method, the IDE shows me the suggetsions like method ,,messages'' or ,,create''. But every time I run the program this error appears:

File "SMS_sending.py", line 1, in <module> from twilio.rest import Client ImportError: No module named twilio.rest

I try restart the computer, uninstall twilio, change the python interpreter to 2.7.9 (my current one is 3.4) but nothing.

Upvotes: 0

Views: 205

Answers (1)

philnash
philnash

Reputation: 73029

Twilio developer evangelist here.

It sounds to me like Pycharm is working with virtualenv but when you run the program you are not within the virtualenv so don't have access to the libraries you have installed in there.

So, on the command line, navigate to your project directory. Then activate the virtualenv:

$ source bin/activate

Then run the program:

$ python SMS_sending.py

Let me know if that helps.

Upvotes: 2

Related Questions