django - 导入错误: No module named south

标签 django python-2.7 django-south

运行 syncdb 时,我收到错误“ImportError:没有名为 South 的模块”。有什么建议吗? Django 1.5.1 和 Python 2.7.5

我认为 South 已经安装,因为我刚刚运行 easy_install South 并得到了

[ckoziak@web415 mvp_landing]$ easy_install south
Searching for south
Best match: South 0.8.1
Processing South-0.8.1-py2.4.egg
South 0.8.1 is already the active version in easy-install.pth

Using /home/ckoziak/lib/python2.4/South-0.8.1-py2.4.egg
Processing dependencies for south
Finished processing dependencies for south

但在此之前我运行了 pip install South 并得到:

[ckoziak@web415 mvp_landing]$ ls
join  manage.py  mvp_landing  static
[ckoziak@web415 mvp_landing]$ pip install south
Traceback (most recent call last):
File "/home/ckoziak/bin/pip", line 7, in ?
sys.exit(
File "/usr/local/lib/python2.4/site-packages/pkg_resources.py", line 277, in       load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.4/site-packages/pkg_resources.py", line 2180, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.4/site-packages/pkg_resources.py", line 1913, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/ckoziak/lib/python2.4/pip-1.4-py2.4.egg/pip/__init__.py", line 10, in ?
from pip.util import get_installed_distributions, get_prog
File "/home/ckoziak/lib/python2.4/pip-1.4-py2.4.egg/pip/util.py", line 17, in ?
from pip.vendor.distlib import version
File "/home/ckoziak/lib/python2.4/pip-1.4-py2.4.egg/pip/vendor/__init__.py", line 8
from __future__ import absolute_import
SyntaxError: from __future__ imports must occur at the beginning of the file

'south'在我的设置文件中。我有一个本地版本和实时版本,其中 __init__ 加入了它们

__init__:

from .base import *

try:
    from .local import *
except:
    pass

try:
    from .live import *
except:
    pass

.local(设置文件),减去数据库信息:

MEDIA_ROOT = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "media")

STATIC_ROOT =  os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "static-only")

STATICFILES_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "static"),
)

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "templates"),
    )
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'south',
'join',
)   

.live(设置文件)尚未设置数据库:

MEDIA_ROOT = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "media")

STATIC_ROOT =  os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "static-only")

STATICFILES_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "static"),
)

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "templates"),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'south',
    'join',
)   

最佳答案

错误消息表明您安装了 Python 2.4。

您应该将 South 安装到 python 2.7。

关于django - 导入错误: No module named south,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18030025/

相关文章:

Python、嵌套循环、匹配和性能

python-2.7 - 关于没有 Root 访问权限的 easy_install 的一些困惑

django - 目前使用 Django "Evolution", "South"更好,值得切换吗?

mysql - 如何使用单个 .csv 文件更新数据库(Django)中的多个表?

Python:检测数据危害的脚本

django - contenttypes.contenttype 在此迁移中不可用

Django 数据库在迁移中挂起

python - 运行 django 时,Twisted 服务器意外崩溃

python - Django 模型字段需要在具有共享抽象基类的多个模型中是唯一的

django - Django 支持 JOIN 吗?