python – Django:ImportError:无法导入名称_compare_digest
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – Django:ImportError:无法导入名称_compare_digest,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3038字,纯文字阅读大概需要5分钟。
内容图文
![python – Django:ImportError:无法导入名称_compare_digest](/upload/InfoBanner/zyjiaocheng/818/e73776f611e64e4690bb440d88f4834c.jpg)
我从网站上安装了Pang和Python 2.7.8的Django 1.6.5.
我运行django-admin.py startproject test123,切换到test123目录,并运行命令python manage.py runserver,然后我得到这个:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 50, in _setup
self._configure_logging()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 72, in _configure_logging
from django.utils.log import DEFAULT_LOGGING
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/log.py", line 7, in <module>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/views/debug.py", line 10, in <module>
from django.http import (HttpResponse, HttpResponseServerError,
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/http/__init__.py", line 2, in <module>
from django.http.request import (HttpRequest, QueryDict, UnreadablePostError,
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/http/request.py", line 11, in <module>
from django.core import signing
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/signing.py", line 45, in <module>
from django.utils.crypto import constant_time_compare, salted_hmac
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/crypto.py", line 6, in <module>
import hmac
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
发现该运算符是一个标准的python库.为什么不能导入呢?
附:我在命令行中尝试过,我可以导入运算符模块,但是我在这个语句中得到一个错误:来自operator import _compare_digest作为compare_digest
解决方法:
跟着这个SO回答:
Uninstall python.org version of python2.7 in favor of default OS X python2.7
然后将我的.bash_profile Python路径更改为/usr/lib / python以获取默认的OSX python路径.
卸载了Django和MySQL-Python:
sudo pip uninstall django
sudo pip uninstall MySQL-Python
然后再次重新安装一切,但MySQL-Python是第一个和第二个Django.
完成这些步骤后,一切正常.
内容总结
以上是互联网集市为您收集整理的python – Django:ImportError:无法导入名称_compare_digest全部内容,希望文章能够帮你解决python – Django:ImportError:无法导入名称_compare_digest所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。