2016-03-19 56 views
1

我的操作系统是OSX El Capitan。django-scarface不能在Python中工作2.7

版本:

  • 的Python 2.7.10
  • 的Django 1.9.2
  • Django的刀疤脸3.0

我安装疤面煞星,并把它添加到安装的应用程序后,它给这个错误,我不能运行我的应用程序。

Unhandled exception in thread started by <function wrapper at 0x1043dbe60> 
Traceback (most recent call last): 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run 
    autoreload.raise_last_exception() 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception 
    six.reraise(*_exception) 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate 
    app_config.import_models(all_models) 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models 
    self.models_module = import_module(models_module_name) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/scarface/models.py", line 7, in <module> 
    from scarface.platform_strategy import get_strategies 
    File "/Users/mcagataybarin/molocate-dev/env/lib/python2.7/site-packages/scarface/platform_strategy.py", line 38 
    class PlatformStrategy(metaclass=ABCMeta): 
            ^
SyntaxError: invalid syntax 

当我搜索这个错误后,我认为这是我的Python版本。 但我不确定,所以我在问你。

有什么办法解决这个问题吗?如果原因真的是我的Python版本,我如何更新我的Python版本而不损坏我的代码和一切?

回答

1

在包装说明Python 2.7支持https://github.com/dreipol/django-scarface/blob/master/setup.py#L30

您可以在Python 2.7.10的virtualenv中运行包测试https://github.com/dreipol/django-scarface/blob/master/scarface/tests.py以查看它们是否通过。如果他们没有,那么你的代码没有问题。如果他们确实通过了,那么问题可能不在包中。

+0

我解决不了的问题:我在github上的项目提交pull请求

class PlatformStrategy(): __metaclass__ = ABCMeta 

。所以我已经将我的python版本更新到3.4.3,并且在解决兼容性问题几个小时后,现在它终于起作用了:) –

+0

太棒了!如果你看到它,你可以将你的问题提交给Github作为一个错误,这个包的其他用户可能不会遇到与你一样的问题。 –