web-dev-qa-db-ja.com

requirements.txtエラーのため、HerokuでDjangoアプリをデプロイできません

Herokuに作成したDjangoアプリをデプロイしようとしています。git Push heroku masterを実行すると、remote: cp: cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directoryのエラーが表示されます。

ここに完全なログがあります:

Enumerating objects: 35, done.
Counting objects: 100% (35/35), done.
Delta compression using up to 2 threads
Compressing objects: 100% (32/32), done.
Writing objects: 100% (35/35), 12.68 KiB | 405.00 KiB/s, done.
Total 35 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: cp: cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directory
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote:        Collecting asgiref==3.2.7
remote:          Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
remote:        Collecting astroid==2.3.3
remote:          Downloading astroid-2.3.3-py3-none-any.whl (205 kB)
remote:        Collecting colorama==0.4.3
remote:          Downloading colorama-0.4.3-py2.py3-none-any.whl (15 kB)
remote:        Collecting dj-database-url==0.5.0
remote:          Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
remote:        Collecting Django==3.0.5
remote:          Downloading Django-3.0.5-py3-none-any.whl (7.5 MB)
remote:        Collecting Django-heroku==0.3.1
remote:          Downloading Django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
remote:        Collecting gunicorn==20.0.4
remote:          Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
remote:        Collecting isort==4.3.21
remote:          Downloading isort-4.3.21-py2.py3-none-any.whl (42 kB)
remote:        Collecting lazy-object-proxy==1.4.3
remote:          Downloading lazy_object_proxy-1.4.3-cp36-cp36m-manylinux1_x86_64.whl (55 kB)
remote:        Collecting mccabe==0.6.1
remote:          Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
remote:        Collecting psycopg2==2.8.5
remote:          Downloading psycopg2-2.8.5.tar.gz (380 kB)
remote:        Collecting pylint==2.4.4
remote:          Downloading pylint-2.4.4-py3-none-any.whl (302 kB)
remote:        Collecting pytz==2019.3
remote:          Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB)
remote:        Collecting six==1.14.0
remote:          Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
remote:        Collecting sqlparse==0.3.1
remote:          Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
remote:        Collecting typed-ast==1.4.1
remote:          Downloading typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (737 kB)
remote:        Collecting whitenoise==5.0.1
remote:          Downloading whitenoise-5.0.1-py2.py3-none-any.whl (20 kB)
remote:        Collecting wrapt==1.11.2
remote:          Downloading wrapt-1.11.2.tar.gz (27 kB)
remote:        Building wheels for collected packages: psycopg2, wrapt
remote:          Building wheel for psycopg2 (setup.py): started
remote:          Building wheel for psycopg2 (setup.py): finished with status 'done'
remote:          Created wheel for psycopg2: filename=psycopg2-2.8.5-cp36-cp36m-linux_x86_64.whl size=447249 sha256=8c3101c70eafd1ccd9ef08021cf553d3c10d55ac62b1c191b19735ab3c026e5a
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-025326ex/wheels/52/9a/ab/22a0d1dc560ad5c0d09cc1c968015f89726e7e01c190dee110
remote:          Building wheel for wrapt (setup.py): started
remote:          Building wheel for wrapt (setup.py): finished with status 'done'
remote:          Created wheel for wrapt: filename=wrapt-1.11.2-cp36-cp36m-linux_x86_64.whl size=69767 sha256=974a65540f5d88c324d2c7cd1c4379cbaa7e2c1a03e599864be4c2ffbe4e17af
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-025326ex/wheels/0d/85/48/15d7bfab92a2d0e87372224c1f628fc57db7447a663a58e86c
remote:        Successfully built psycopg2 wrapt
remote:        Installing collected packages: asgiref, lazy-object-proxy, typed-ast, six, wrapt, astroid, colorama, dj-database-url, sqlparse, pytz, Django, psycopg2, whitenoise, Django-heroku, gunicorn, isort, mccabe, pylint
remote:        Successfully installed Django-3.0.5 asgiref-3.2.7 astroid-2.3.3 colorama-0.4.3 dj-database-url-0.5.0 Django-heroku-0.3.1 gunicorn-20.0.4 isort-4.3.21 lazy-object-proxy-1.4.3 mccabe-0.6.1 psycopg2-2.8.5 pylint-2.4.4 pytz-2019.3 six-1.14.0 sqlparse-0.3.1 typed-ast-1.4.1 whitenoise-5.0.1 wrapt-1.11.2
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 21, in <module>
remote:            main()
remote:          File "manage.py", line 17, in main
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/management/__init__.py", line 401, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/management/__init__.py", line 395, in execute
remote:            self.fetch_command(subcommand).run_from_argv(self.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/management/base.py", line 328, in run_from_argv
remote:            self.execute(*args, **cmd_options)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/management/base.py", line 369, in execute
remote:            output = self.handle(*args, **options)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
remote:            collected = self.collect()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/contrib/staticfiles/management/commands/collectstatic.py", line 104, in collect
remote:            for path, storage in Finder.list(self.ignore_patterns):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/contrib/staticfiles/finders.py", line 130, in list
remote:            for path in utils.get_files(storage, ignore_patterns):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/contrib/staticfiles/utils.py", line 23, in get_files
remote:            directories, files = storage.listdir(location)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/files/storage.py", line 316, in listdir
remote:            for entry in os.scandir(path):
remote:        FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_8b272f59d204dc1b5699579647b39ae3/static_in_env'
remote:
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote:
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote:        https://devcenter.heroku.com/articles/Django-assets
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to pure-plains-36964.
remote:
To https://git.heroku.com/pure-plains-36964.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to Push some refs to 'https://git.heroku.com/pure-plains-36964.git'

すべてのものが含まれているルートディレクトリにrequirements.txtがあります。助けてください

2
iscream

確かにrequirements.txtエラーがありますが、ビルドは停止しません。

エラーはあなたのDjango collectstaticにあるものです。呼び出されたstatic_in_envに空のフォルダがあるためである可能性があります。スタックトレースの推奨事項に従うことができます。実行:

$ heroku config:set DISABLE_COLLECTSTATIC=1

ただし、collectstaticを実行する必要がある場合は、そのフラグを元に戻します。

$ heroku config:set DISABLE_COLLECTSTATIC=0

次に、それが空である理由をデバッグします。これ以上の文脈なしでは、言うのは難しいです。

requirements.txtについては、requirements.txtが1つだけであることを確認してください。複数ある場合は、すべてにテキストが含まれていることを確認してください。お役に立てれば。

0
plumSemPy