Django:尝试从GitHub使用django-audiofield时导入错误

时间:2012-10-15 01:05:29

标签: python django aptana

我正在尝试在我的django项目中使用django application on Github called django-audiofield。我正在使用Aptana Studio IDE。我在我的虚拟环境中安装它,我收到以下错误:

Traceback (most recent call last):
    File "/Users/home/Desktop/Web Development/Aptana Studio 3.0/musicproject/src/manage.py",    line 10, in <module>
    execute_from_command_line(sys.argv)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/commands/validate.py", line 9, in handle_noargs
    self.validate(display_num_errors=True)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
    self._populate()
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/db/models/loading.py", line 67, in _populate
    self.load_app(app_name)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
    models = import_module('.models', app_name)
    File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
    File "/Users/home/virtualenv/venv/src/audiofield/audiofield/models.py", line 19, in <module>
    from audiofield.fields import AudioField
    File "/Users/home/virtualenv/venv/src/audiofield/audiofield/fields.py", line 20, in <module>
    from tasks import audio_convert_task
    File "/Users/home/virtualenv/venv/src/audiofield/audiofield/tasks.py", line 14, in <module>
    from celery.task import Task
  ImportError: No module named celery.task
Finished "/Users/home/Desktop/Web Development/Aptana Studio 3.0/musicproject/src/manage.py validate" execution.

请协助。

2 个答案:

答案 0 :(得分:3)

我是该软件包的维护者,感谢您的帖子我意识到我们在要求中缺少芹菜/ django-celery。它现在已添加到最新版本中。

所以“pip install django-audiofield”会为你安装这些依赖项。 如果已经安装了django-audiofield,则可以运行以下命令进行升级:“pip install django-audiofield --upgrade”

答案 1 :(得分:1)

您安装了celery吗?如果不是,请安装芹菜(pip install celery)。如果有问题的github应用程序(链接本来不错)在任何地方都有一个requirements.txt文件,请pip install -r requirements.txt安装应用程序的所有必需依赖项。

如果是,看起来您的import search path可能无法正确设置以查找Celery - 只是根据导入错误进行猜测。

打开django shell(当你在项目的工作目录中时键入python manage.py shell)并输入import sys; print sys.path。确保Celery安装在其中一个目录中,因为sys.path指定了python模块的导入搜索路径。

如果它没有包含在那里,你可以通过sys.path.append("<directory where celery is>")临时追加安装芹菜的目录(注意反斜杠,因为你在Windows上)。如果在执行此操作后,您可以成功from celery.tasks import Task,那么您可以适当地设置PYTHONPATH环境变量以使其永久化。

此外,由于您已将Celery安装到virtualenv中,因此可能需要检查django和Celery是否属于同一个虚拟环境。

最后,Celery的最新提交表明Celery now has native Django support,但由于尚未作为稳定版本发布,您可能需要查看django-celery

修改(以回应以下评论):

既然你提到你试图让django-audiofield工作:它似乎be on pypi。这意味着一旦安装了所有必需的(非python)依赖项,就可以使用pip(或easy_install)使用pip install django-audiofield安装它,并且应该为你下载像celery这样的东西。