Twilio import error in python shell - macos

Installed Twilio successfully however when I attempt to import it in either the shell or terminal I get this error output:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import twilio
File "/Library/Python/2.7/site-packages/twilio/__init__.py", line 11, in <module>
from .rest.exceptions import TwilioRestException
File "/Library/Python/2.7/site-packages/twilio/rest/__init__.py", line 1, in <module>
from .base import set_twilio_proxy
File "/Library/Python/2.7/site-packages/twilio/rest/base.py", line 6, in <module>
from twilio.rest.resources import Connection
File "/Library/Python/2.7/site-packages/twilio/rest/resources/__init__.py", line 1, in <module>
from .util import (
File "/Library/Python/2.7/site-packages/twilio/rest/resources/util.py", line 5, in <module>
import pytz
ImportError: No module named pytz
Can anyone explain what is happening here? My version of Python is 2.7.9 and my pip installer is current as well. Output Error above is from importing in IDLE shell.

Twilio developer evangelist here.
The Twilio library requires pytz to be installed. Easiest way to get it installed is by running this on your terminal:
pip install pytz
Hope this helps

Related

Problem installing importlib on Mac with pip3

Good morning!
Until yesterday I was using python 2.7 and using the following code for writing output files for my scripts:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
But now I'm upgrading my code to python 3.7, so now I need to use importlib.reloadinstead of just reload. However, typing sudo -H pip3 install importlib on my shell gives me the following error:
Collecting importlib
Using cached https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 6, in <module>
import distutils.core
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 16, in <module>
from distutils.dist import Distribution
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 19, in <module>
from distutils.util import check_environ, strtobool, rfc822_escape
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/util.py", line 9, in <module>
import importlib.util
ModuleNotFoundError: No module named 'importlib.util'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-3cz_3d6n/importlib/
After looking for solutions I also tried to upgrade setuptools, but that didn't fix my problem.
Many thanks in advance!
importlib at PyPI is an outdated package intended for very old Python versions. For new versions of Python importlib is a module from the standard library, you don't need to install it, it's always available.

sklearn: ImportError: DLL load failed: The specified module could not be found

Ive updated my Python version from 3.5.4 to 3.6.6 (in Anaconda 3) and now the line
from sklearn.metrics.pairwise import cosine_similarity
causes the following error:
Traceback (most recent call last):
File "<ipython-input-3-743ac88bcf9a>", line 1, in <module>
from sklearn.metrics.pairwise import cosine_similarity
File "F:\Program Files\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "F:\Program Files\lib\site-packages\sklearn\base.py", line 13, in <module>
from .utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\__init__.py", line 13, in <module>
from .validation import (as_float_array,
File "F:\Program Files\lib\site-packages\sklearn\utils\validation.py", line 22, in <module>
from ..utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\fixes.py", line 83, in <module>
from scipy.special import boxcox # noqa
File "F:\Program Files\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
Im on Windows 7, 64-bit; previously the line worked fine, and other packages (Pandas, Numpy etc) still work, so it doesn't appear to be a PATH issue as some have suggested.
Ive seen numerous similar questions but all solutions have so far failed. E.g.
roll the installation back to Python 3.5.4,
uninstall & re-install Pandas, Numpy, Scipy and Sklearn, also update MKL/MKL-RT.
The changes suggested in Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found
were already implemented
Does anyone have any further suggestions (specific to Anaconda etc)?
I solved it, and (in my case) the problem was scipy, not sklearn.
What i did was uninstall scipy with conda: conda remove --force scipy, and then install it with pip: pip install scipy. That worked for me.

Installed Miniconda 4.2.11 and have import error while creating environment

I am able to create environment from environment.yml file which has release number 4.2.7 but recently updated miniconda distribution on my Desktop to 4.2.11. Can I go back to my previous distribution?
Snippet of the error:
Traceback (most recent call last):
File "/Users/ramya/miniconda2/bin/conda-env", line 4, in <module>
import conda_env.cli.main
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/cli/main.py", line 35, in <module>
from . import main_attach
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/cli/main_attach.py", line 4, in <module>
from ..env import from_environment
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/env.py", line 17, in <module>
from . import yaml
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/yaml.py", line 8, in <module>
import yaml
Answering my own question here - I got hold of a previous download of Miniconda (Miniconda2-latest-MacOSX-x86_64.sh) Installation file and created my environment which resolved my problem.

Pylint Error - no module named astroid

I've recently installed pylint on a windows 7 and when I run it I get the error:
Error executing PyLint: Command failed with error=None, status=1; stderr:
Traceback (most recent call last):
File "C:\Python27\Scripts\pylint", line 3, in <module>
run_pylint()
File "c:\python27\lib\site-packages\pylint\__init__.py", line 20, in run_pylint
from pylint.lint import Run
File "c:\python27\lib\site-packages\pylint\lint.py", line 30, in <module>
from pylint.checkers import utils #pylint: disable=unused-import
File "c:\python27\lib\site-packages\pylint\checkers__init__.py", line 47, in
from pylint.reporters import diff_string
File "c:\python27\lib\site-packages\pylint\reporters__init__.py", line 20, in
from pylint.utils import MSG_TYPES
File "c:\python27\lib\site-packages\pylint\utils.py", line 32, in
from astroid import nodes, Module
ImportError: No module named astroid
I've followed the install instructions as best I can but can't seem to get past this.
Use this link to install pip properly How do I install pip on Windows?
then do the pip install pylint
then do go through this note http://docs.pylint.org/installation.html#note-for-windows-users

issue with python 3.4+ and pip

I installed pip 3.4 recently , however i cant seem to use pip properly ( which is included with the latest python 3) it gives me this error whenever i attempt to import it :
"Traceback (most recent call last)
File "<pyshell#8>", line 1, in <module>
import pip
File "C:\Python34\lib\site-packages\pip\__ini... line 9, in <module>
from pip.log import logger
File "C:\Python34\lib\site-packages\pip\log.p... line 8, in <module>
from pip import backwardcompat
File "C:\Python34\lib\site-packages\pip\backw... line 27, in <module>
console_encoding = sys.__stdout__.encoding
AttributeError: 'NoneType' object has no attribute 'encoding"``
If you are using python under WIN OS, pip works as a WIN command: try to directly type "pip install .package." in your cmd shell.

Resources