gpt4 book ai didi

python - 运行结构脚本抛出 ImportError : No module named celery

转载 作者:行者123 更新时间:2023-11-28 19:22:17 25 4
gpt4 key购买 nike

我已经撕裂了很长一段时间了。

只要我运行任何结构脚本,它就会抛出 ImportError: No module named celery 源 self 的 proj/proj/celery.py 文件。这是怎么回事?

完整回溯:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 658, in main
docstring, callables, default = load_fabfile(fabfile)
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 165, in load_fabfile
imported = importer(os.path.splitext(fabfile)[0])
File "/home/username/Projects/proj/fabfile/__init__.py", line 2, in <module>
from .staging import *
File "/home/username/Projects/proj/fabfile/staging.py", line 3, in <module>
from proj.settings.staging import DOMAIN, IP, USER, PASSWORD
File "/home/username/Projects/proj/proj/__init__.py", line 5, in <module>
from .celery import app as celery_app
File "/home/username/Projects/proj/proj/celery.py", line 3, in <module>
from celery import Celery
ImportError: No module named celery

编辑:我不认为我的结构脚本的内容与它有任何关系。为了举例我设置:

from fabric.api import local
def foo():
local('echo bar')

调用 fab foo 引发 ImportError: No module named celery。实际上,如果我只调用 fab,结果是一样的。

我的proj/proj/__init__.py:

from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

就像在 celery tutorial 中一样

编辑:

这个有效:

(venv)rg@dfi:~/Projects/proj$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from celery import Celery
>>>

最佳答案

解决方法是安装系统范围的 celery ,但这显然不是 fabric 所期望的行为。

关于python - 运行结构脚本抛出 ImportError : No module named celery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22310628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com