pytz 安装在 Mac
pytz install on Mac
Django 通知我 "ImportError: No module named pytz",但是当我去使用 pip 安装它时,我得到了这个结果:
Requirement already satisfied (use --upgrade to upgrade): pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
有没有可能它在错误的位置寻找,或者我需要尝试将它安装到其他地方?
这是完整的堆栈跟踪:
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
谢谢
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras
是与 Apple 提供的 Python 2.7 (/usr/bin/python2.7
) 关联的位置。不可能从回溯中分辨出来,但 Django 有可能 运行 在 Python 2.7 的不同实例下,可能链接到 /usr/local/bin
。当存在 Python 的多个实例并且您直接从命令行使用 pip
时,可能会出现此类问题。确保为您正在使用的每个 Python 安装了一个 pip
版本。而且,为了确保您使用的是 pip
的正确实例,您可以这样调用它:
python -m pip install pytz
将 python
替换为用于 运行 Django 的相同路径。
另一种方法是始终使用激活的 virtualenv
,这应确保首先在进程 PATH
上找到正确的 python
和 pip
实例。
Django 通知我 "ImportError: No module named pytz",但是当我去使用 pip 安装它时,我得到了这个结果:
Requirement already satisfied (use --upgrade to upgrade): pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
有没有可能它在错误的位置寻找,或者我需要尝试将它安装到其他地方?
这是完整的堆栈跟踪:
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
谢谢
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras
是与 Apple 提供的 Python 2.7 (/usr/bin/python2.7
) 关联的位置。不可能从回溯中分辨出来,但 Django 有可能 运行 在 Python 2.7 的不同实例下,可能链接到 /usr/local/bin
。当存在 Python 的多个实例并且您直接从命令行使用 pip
时,可能会出现此类问题。确保为您正在使用的每个 Python 安装了一个 pip
版本。而且,为了确保您使用的是 pip
的正确实例,您可以这样调用它:
python -m pip install pytz
将 python
替换为用于 运行 Django 的相同路径。
另一种方法是始终使用激活的 virtualenv
,这应确保首先在进程 PATH
上找到正确的 python
和 pip
实例。