Python Heroku migrate:ModuleNotFoundError(可能存在静态错误)

Python Heroku migrate:ModuleNotFoundError(可能存在静态错误),python,django,heroku,static,Python,Django,Heroku,Static,我遇到了与、和和相同的问题。然而,我试图回答这些问题中的每一个,但都没有结果 在尝试部署应用程序时,请使用以下命令: heroku运行python manage.py migrate 错误 Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/p

我遇到了与、和和相同的问题。然而,我试图回答这些问题中的每一个,但都没有结果

在尝试部署应用程序时,请使用以下命令:

heroku运行python manage.py migrate

错误

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 224, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 14, in <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 11, in <module>
    from django.db.migrations.questioner import MigrationQuestioner
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/questioner.py", line 9, in <module>
    from .loader import MigrationLoader
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 8, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 9, in <module>
    class MigrationRecorder:
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 22, in MigrationRecorder
    class Migration(models.Model):
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 87, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 249, in get_containing_app_config
    self.check_apps_ready()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 131, in check_apps_ready
    settings.INSTALLED_APPS
  File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 57, in __getattr__
    self._setup(name)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 107, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/app/mapping_data/settings.py", line 2, in <module>
    from decouple import config
ModuleNotFoundError: No module named 'decouple'
设置.py

INSTALLED_APPS = [
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# The absolute path to the directory where collectstatic will collect static files for deployment
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
PROJECT_PATH = os.path.abspath(os.path.dirname(__name__))
# The URL to use when referring to static files (where they will be served from)
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
    os.path.join(PROJECT_ROOT, 'static'),
]
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
ROOT_URLCONF = 'mapping_data.urls'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)
MEDIA_ROOT = (
BASE_DIR
)
Pipfile

[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]

django = "==2.1.2"

[dev-packages]
结构
如@Selcuk所述,问题是忽略了
Pipfile
requirements.txt

根据
requirements.txt
将依赖项转换为
pipenv
所需的步骤如下:

$pip安装pipenv

$pipenv安装-r requirements.txt

$pipenv锁


它们似乎是独立的问题。你能发布你的
Pipfile
的内容吗?我现在包括了
Pipfile
这只是一个猜测,但可能是当存在
Pipfile
时,你正在部署的Heroku堆栈忽略了
requirements.txt
。您能否尝试在
[packages]
下添加
python decouple=“==3.1”
?我遵循了您的建议,仍然得到了完全相同的错误。如果有任何帮助,我已经在上面的查询中包含了完整的回溯。谢谢@Selcuk you ware,问题是,正如您在评论中可能假设的那样,在
Pipfile
中添加
python decouple
[packages]
之后,我没有运行
$pipenv lock
[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]

django = "==2.1.2"

[dev-packages]
.git
__pycache__
htmlcov
mapping_data
     __pycache__
     static
         .keep
     __init__.py
     settings.py
     urls.py
     wsgi.py
mapping_twitter
     __pycache__
     migrations
     static
         css
             styles.css
         mapping_twitter
             histogram.png
     templates
     tests
     __init__.py
     admin.py
     apps.py
     forms.py
     models.py
     urls.py
     views.py
.coverage
.editorconfig
.env
.gitignore
db.sqlite3
ghostdriver.log
manage.py
Pipfile
Pipfile.lock
Procfile
requirements.txt
runtime.txt