Django依赖:hmac?

时间:2014-06-21 01:22:07

标签: python django

我今天做了很多改变,包括环境变量,Pyscripter以及从2.7.5到2.7.7更新Python。当我尝试在我的Django站点上 runserver 时,其中一个更改现在会引发错误。

(myEnv)PS C:\Users\Josh\.virtualenvs\myEnv\tumblr> python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 261, in fetch_command
    commands = get_commands()
  File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 107, in get_commands
    apps = settings.INSTALLED_APPS
  File "C:\Python27\Lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
    self._setup(name)
  File "C:\Python27\Lib\site-packages\django\conf\__init__.py", line 50, in _setup
    self._configure_logging()
  File "C:\Python27\Lib\site-packages\django\conf\__init__.py", line 72, in _configure_logging
    from django.utils.log import DEFAULT_LOGGING
  File "C:\Python27\Lib\site-packages\django\utils\log.py", line 7, in <module>
    from django.views.debug import ExceptionReporter, get_exception_reporter_filter
  File "C:\Python27\Lib\site-packages\django\views\debug.py", line 10, in <module>
    from django.http import (HttpResponse, HttpResponseServerError,
  File "C:\Python27\Lib\site-packages\django\http\__init__.py", line 2, in <module>
    from django.http.request import (HttpRequest, QueryDict, UnreadablePostError,
  File "C:\Python27\Lib\site-packages\django\http\request.py", line 11, in <module>
    from django.core import signing
  File "C:\Python27\Lib\site-packages\django\core\signing.py", line 45, in <module>
    from django.utils.crypto import constant_time_compare, salted_hmac
  File "C:\Python27\Lib\site-packages\django\utils\crypto.py", line 6, in <module>
    import hmac
  File "C:\Python27\Lib\hmac.py", line 8, in <module>
    from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest

我尝试过更新Django,但我有最新版本。接下来是卸载Django并重新安装它,如果这不会弄乱我的项目。有任何想法吗?非常感谢!

1 个答案:

答案 0 :(得分:4)

我在网上通过以下链接找到的一个建议是重置你的virtualenv,因为升级到Python 2.7.7后会出现此错误。运行

# virtualenv /path/to/your/virtualenv/

并且应该使用最新的python重置它。

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749491

对我来说,降级到python 2.7.6并且现在我的django 1.6.5应用程序再次正常工作。