2016-10-30 56 views
0

我有一個項目在dev VM'ubuntu/trusty'下。 我用的virtualenv與以下軟件包:以項目名稱作爲命令行參數啓動芹菜發出錯誤

celery 3.1.23 
eventlet 0.18.4 
django 1.8.15 

Python版本3.4.3是。

當我開始以這種方式芹菜工人:

celery worker --loglevel=INFO -P eventlet -c 3 -Q default -E -n default.queue -l INFO 

它正確地啓動,但是所有的任務留在「掛起」狀態。

當我開始是這樣(與項目的名稱'-A'參數):

celery worker -A meridian --loglevel=INFO -P eventlet -c 3 -Q default -E -n default.queue -l INFO 

它發出了一個錯誤:

(meridian)[email protected]:/vagrant/meridian/meridian$ celery worker -A meridian --loglevel=INFO -P eventlet -c 3 -Q default -E -n default.queue -l INFO 
Traceback (most recent call last): 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/app/utils.py", line 241, in find_app 
    found = sym.app 
AttributeError: 'module' object has no attribute 'app' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/home/vagrant/.virtualenvs/meridian/bin/celery", line 11, in <module> 
    sys.exit(main()) 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/__main__.py", line 30, in main 
    main() 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/bin/celery.py", line 81, in main 
    cmd.execute_from_commandline(argv) 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/bin/celery.py", line 793, in execute_from_commandline 
    super(CeleryCommand, self).execute_from_commandline(argv))) 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/bin/base.py", line 309, in execute_from_commandline 
    argv = self.setup_app_from_commandline(argv) 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/bin/base.py", line 469, in setup_app_from_commandline 
    self.app = self.find_app(app) 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/bin/base.py", line 489, in find_app 
    return find_app(app, symbol_by_name=self.symbol_by_name) 
    File "/home/vagrant/.virtualenvs/meridian/lib/python3.4/site-packages/celery/app/utils.py", line 246, in find_app 
    found = sym.celery 
AttributeError: 'module' object has no attribute 'celery' 

有誰知道如何解決?

回答

1

看來你的項目(應用程序)是不可導入的。

您的選擇:

  • 創建一個適當的Python包(setup.py),與pip install /project/directory安裝。這將創建副本您的文件在virtualenv/lib/python-version/site-packages/。靠書,但很少使用的方法。
  • pip install -e /project/directory也需要setup.py,將項目符號鏈接到站點包中,所以它對每個virtualenv都是一次性操作。在包開發人員中廣泛使用。
  • 在導入項目之前,請注意Python代碼中的sys.path。示例: import sys sys.path.append('/project/directory')
  • 通過PYTHONPATH環境變量處理導入目錄。通常依賴於平臺的規則適用於PATH規則(在Windows中,由:分隔的條目除外,但在Windows上爲;)。這種方式在部署中非常流行。例如,在外殼: export PYTHONPATH=/project/directory exec /virtualenv/bin/celery worker ...
+0

謝謝,但我不確定你在'同一個virtualenv'中安裝你的項目是什麼意思。 virtualenv創建特殊的目錄包含所需的python庫和/或特定的python版本,不是嗎?我如何在那裏「安裝」項目? –

+1

請參閱上面的更新 – temoto

相關問題