开发者社区> 问答> 正文

Django-Python RunServer时的其余框架错误

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/dj_static.py", line 83, in __call__
    return self.application(environ, start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
    response = self.get_response(request)
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 220, in handle_uncaught_exception
    if resolver.urlconf_module is None:
  File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/WillRedington/Desktop/Django Projects/propadev/propvocab/urls.py", line 3, in <module>
    from rest_framework import routers
  File "/Library/Python/2.7/site-packages/rest_framework/routers.py", line 23, in <module>
    from rest_framework import views
  File "/Library/Python/2.7/site-packages/rest_framework/views.py", line 11, in <module>
    from rest_framework.compat import HttpResponseBase, View
  File "/Library/Python/2.7/site-packages/rest_framework/compat.py", line 13, in <module>
    from django.utils.six.moves.urllib import parse as urlparse
ImportError: No module named urllib

服务器错误消息:[17 / Dec / 2014 16:26:45]“ GET / HTTP / 1.1” 500 59

这正在检查python是否返回模块:

>>> import django.utils.six.moves
>>> import django.utils.six.moves.urllib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named urllib
>>>

我当前的python版本是2.7.2,Django是1.5.1,其余框架在2.7 site-package中。我已经尝试过多次卸载并重新安装Django并得到相同的错误。这是在Mac OS X 10.9.5上运行的,请帮助我,我已经参加了5个小时。

展开
收起
祖安文状元 2020-02-22 15:32:28 523 0
1 条回答
写回答
取消 提交回答
  • 似乎是一个依赖错误。也许您降级了django,或在不控制依赖项的情况下随机安装了其余框架包。

    django == 1.5.1中尚不存在django.utils.six.moves.urllib。例如,您可以尝试将django升级到1.5.7。然后,此导入将起作用。但是,我无法从这里告诉您其他问题。如果在此处发布点子冻结的输出,可能会更容易帮助。

    您不在虚拟环境中工作,这对依赖关系很危险。最好是制作一个virtualenv,然后使用pip安装软件包,并注意相关性。然后运行:

    pip freeze > requirements.txt
    
    

    并在以后像这样使用该文件:

    pip install -r requirements.txt
    
    

    并在安装,更新或删除软件包时相应地编辑文件。

    可能感兴趣的是:通常,多次卸载并重新安装同一软件包永远不会起作用;如果它一次不起作用,那么第二次也将不起作用。

    2020-02-22 15:32:41
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载