找不到 Django + Heroku 芹菜模块

Django + Heroku celery module not found

我正在尝试将我的最新版本的 webapp 实时推送到 Heroku。我很乐意推动 Heroku,但这似乎不对。出于某种原因,我觉得 Heroku 正在跳过我的 requirements.txt。以防万一我在我的 Heroku 应用程序上手动安装了 celery。

我在使用 celery 时遇到了这个具体问题,但如果 Heroku 跳过了我的 requirements.txt 这可能是一个更大的问题。

1.如果我运行:

heroku run pip install celery

这让我一遍又一遍地安装软件包,它不应该返回一个 "requirement already met" 错误吗?

2. 当我尝试推送到 heroku 时,我不断收到

File "/app/config/_celery.py", line 4, in <module>
from celery import Celery
ModuleNotFoundError: No module named 'celery'

我一直想不通为什么,我卸载了 celery,然后在本地重新安装。它在我的 requirements.txt 上(Heroku 应该在推送到远程时安装它)。芹菜似乎在当地也能正常工作。

我会包括我认为必要的内容,但如果我遗漏了可能提供答案的内容,请告诉我。

这是我的项目文件结构:

POTRTMS(overall project folder)
|
+-config(holds settings)
|  |
|  +--settings
|  |  |
|  |  __init__.py
|  |  production.py
|  |  local.py
|  |  base.py
|  |
|  _celery.py
|  __init__.py (this is the __init__.py i'm referencing below)

_celery.py

from __future__ import absolute_import, unicode_literals
import sys
import os
from celery import Celery
from celery.schedules import crontab

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.production')

app = Celery('POTRTMS')
# Using a string here means the worker don't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

@app.task(bind=True)
def debug_task(self):
  print('Request: {0!r}'.format(self.request))


app.conf.beat_schedule = {
    'insurance_date': {
        'task': 'insurance_date',
        'schedule': crontab(minute=0, hour=8),

    },
}

__init.py__

from __future__ import absolute_import

from ._celery import app as celery_app

我能够找出问题所在。在我的项目根文件夹中,我有 Pipfile 和 Pipfile.lock,这听起来像是一种执行 requirements.txt.

的新方法

我不确定这些文件是如何进入我的项目的,但删除它们后一切正常。