Django informs me "ImportError: No module named pytz", but when I go to use pip to install it, I get this result:
Requirement already satisfied (use --upgrade to upgrade): pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Is it possible that it is looking in the wrong location, or that I need to try to install it somewhere else?
Here is the full stacktrace:
Internal Server Error: /basicloginwebservice/
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 103, in get_response
resolver_match = resolver.resolve(request.path_info)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 321, in resolve
sub_match = pattern.resolve(new_path)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 223, in resolve
return ResolverMatch(self.callback, args, kwargs, self.name)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 230, in callback
self._callback = get_callable(self._callback_str)
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 29, in wrapper
result = func(*args)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 97, in get_callable
mod = import_module(mod_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/<redacted>/django/<redacted>/<redacted>/views.py", line 3, in <module>
import pytz
ImportError: No module named pytz
Thanks
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras
is a location associated with the Apple-supplied Python 2.7 (/usr/bin/python2.7
). It's not possible to tell from the traceback but chances are that Django is being run under a different instance of Python 2.7, perhaps linked to from /usr/local/bin
. These sorts of problems can arise when there are multiple instances of Python and you are using pip
directly from the command line. Make sure you have a version of pip
installed for each Python you are using. And, to ensure that you are using the right instance of pip
, you can invoke it this way:
python -m pip install pytz
substituting for python
the same path that is used to run Django.
Another approach is to always use an activated virtualenv
which should ensure that the right python
and pip
instances are found first on the process PATH
.