"ImportError: no module named twilio.rest"

I installed python 2.7.10 with PATH access and installed twilio correctly. However, when I try to execute the code, I get this error message

Traceback (most recent call last):
  File "C:\Users\tmslvo\Google Drive\Desktop\send text.py", line 1, in <module>
    from twilio.rest import TwilioRestClient
ImportError: No module named twilio.rest

Now I read that the reason may be that python cannot find the twilio package, so I tried

which -a python
which -a twilio

(on my windows command line), in this case I get

'which' is not recognized as an internal or external command,
operable program or batch file.

Does anyone have an idea of ​​what I'm doing wrong?

Thanks!

+4
source share
6 answers

Twilio evangelist developer is here.

I think your problem will be that somehow, when you installed the library, it failed (?). A few things to keep in mind:

  • Python , pip.
  • , , twilio.py, .
  • , Python, , , , python --version

, , , ( ), .

import twilio
import twilio.rest

try:
    client = twilio.rest.TwilioRestClient(account_sid, auth_token)

    message = client.messages.create(
        body="Hello World",
        to="+14159352345",
        from_="+14158141829"
    )
except twilio.TwilioRestException as e:
    print e
+18

. easy_install pip twilio, . , pip uninstall twilio pip.

+2

IDLE.

, ,

+1

Pycharm:

( 2017) python 2.6 2.7. PyCharm 2.6. twilio ( ), python 2.7. , twilio PyCharm,

ImportError: No module named twilio.rest

: python PyCharm. preferences > project interpreter Project Interpreter python 2.7

0

I think your pip is not configured properly. You may receive a message successfully installed, but it does not install where it should be. try pip install --user, I'm sure it will work for you. pip install can only work fine in virtualenvironment without any config. Try pip install --user package name

@iosCurator

0
source

rename a file name other than twilio.py EX: send_sms.py

-1
source

Source: https://habr.com/ru/post/1627165/


All Articles