Import error in twilio

落爺英雄遲暮 提交于 2019-11-28 02:02:47

I named a python file in my project twilio.py. Since that file was loaded first, then subsequent calls to load twilio would reference that file instead of the twilio library.

TLDR: just don't name your python file twilio.py

Check which versions of pip and python you are running with this command:

which -a python
which -a pip

pip needs to install to a path that your Python executable can read from. Sometimes there will be more than one version of pip like pip-2.5, pip-2.7 etc. You can find all of them by running compgen -c | grep pip. There can also be more than one version of Python, especially if you have Macports or brew or multiple versions of Python installed.

Check which version of the twilio module is installed by running this command:

$ pip freeze | grep twilio          # Or pip-2.7 freeze etc.

The output should be twilio==3.3.3.

I hope that helps - please leave a comment if you have more questions.

This Worked For me : (Windows)

Python librarys are in G:\Python\Lib

(Python is installed at G:, it might be different for you)

Download Twilio from github at paste the library at >> G:\Python\Lib <<

import problem gone :)

rSeNaL

I had the same issue and it drove me crazy. Finally I figured it out. When you get the error:

AttributeError: module 'twilio' has no attribute 'version'

Look 2 lines above and the error is telling you where it expects to find the twilio file. So I moved it from where it was to where it was asking it to be.

Installed to:

c:\users\rhuds\appdata\local\programs\python\python37-32\lib\site-packages

Moved it to: Traceback (most recent call last): File "", line 1, in import twilio File "C:\Users\rhuds\AppData\Local\Programs\Python\Python37-32\twilio.py", line 2, in

Now I can import twilio. Besides that, the only other thing I did was uninstall old versions of Python, but I don't think that really mattered.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!