首先,我研究了与此相关的每个堆栈溢出问题。从更新requirements.txt,pipfile.lock,pipfile,添加到已安装的应用程序等。
该软件包可在本地完美运行,但在Heroku上崩溃。从日志看来,它正在读取settings.py,并且当它到达“ markdownx”时,无法找到该名称的模块。我猜是因为它在pipfile.lock,requirements.txt和pipfile中被列为“ django-markdownx”。但是,当我在这些位置将名称更改为“ markdownx”时,它将在本地失败。我花了很多时间在网上查找所有内容以解决此问题,但没有任何效果,因此,我们将不胜感激。以下是我的文件。
Requirements.txt
certifi==2018.11.29
chardet==3.0.4
Django==2.1
django-markdownx==2.0.28
gunicorn==19.9.0
idna==2.8
lxml==4.3.0
Markdown==3.0.1
Pillow==5.4.1
pytz==2018.9
PyYAML==3.13
requests==2.21.0
sorl-thumbnail==12.5.0
urllib3==1.24.1
Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
django-markdownx = "*"
[packages]
django = "==2.1"
gunicorn = "*"
[requires]
python_version = "3.7"
pipfile.lock
{
"_meta": {
"hash": {
"sha256": "e45fc89d2502eac1be6bd0ea7e7189a78db18d760bb7fb386c78350de2271f88"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.7"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"django": {
"hashes": [
"sha256:7f246078d5a546f63c28fc03ce71f4d7a23677ce42109219c24c9ffb28416137",
"sha256:ea50d85709708621d956187c6b61d9f9ce155007b496dd914fdb35db8d790aec"
],
"index": "pypi",
"version": "==2.1"
},
"gunicorn": {
"hashes": [
"sha256:aa8e0b40b4157b36a5df5e599f45c9c76d6af43845ba3b3b0efe2c70473c2471",
"sha256:fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3"
],
"index": "pypi",
"version": "==19.9.0"
},
"pytz": {
"hashes": [
"sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9",
"sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c"
],
"version": "==2018.9"
}
},
"develop": {
"django": {
"hashes": [
"sha256:7f246078d5a546f63c28fc03ce71f4d7a23677ce42109219c24c9ffb28416137",
"sha256:ea50d85709708621d956187c6b61d9f9ce155007b496dd914fdb35db8d790aec"
],
"index": "pypi",
"version": "==2.1"
},
"django-markdownx": {
"hashes": [
"sha256:285a40ab405830c0a049e05f3dafabb2c195146f577b824913555aa62512b90d",
"sha256:d6e706c0b1329b23d6dcaa8754e5921fa2531711dc5afeec4ed3c73a8cb6a178"
],
"index": "pypi",
"version": "==2.0.28"
},
"markdown": {
"hashes": [
"sha256:c00429bd503a47ec88d5e30a751e147dcb4c6889663cd3e2ba0afe858e009baa",
"sha256:d02e0f9b04c500cde6637c11ad7c72671f359b87b9fe924b2383649d8841db7c"
],
"version": "==3.0.1"
},
"pillow": {
"hashes": [
"sha256:051de330a06c99d6f84bcf582960487835bcae3fc99365185dc2d4f65a390c0e",
"sha256:0ae5289948c5e0a16574750021bd8be921c27d4e3527800dc9c2c1d2abc81bf7",
"sha256:0b1efce03619cdbf8bcc61cfae81fcda59249a469f31c6735ea59badd4a6f58a",
"sha256:163136e09bd1d6c6c6026b0a662976e86c58b932b964f255ff384ecc8c3cefa3",
"sha256:18e912a6ccddf28defa196bd2021fe33600cbe5da1aa2f2e2c6df15f720b73d1",
"sha256:24ec3dea52339a610d34401d2d53d0fb3c7fd08e34b20c95d2ad3973193591f1",
"sha256:267f8e4c0a1d7e36e97c6a604f5b03ef58e2b81c1becb4fccecddcb37e063cc7",
"sha256:3273a28734175feebbe4d0a4cde04d4ed20f620b9b506d26f44379d3c72304e1",
"sha256:4c678e23006798fc8b6f4cef2eaad267d53ff4c1779bd1af8725cc11b72a63f3",
"sha256:4d4bc2e6bb6861103ea4655d6b6f67af8e5336e7216e20fff3e18ffa95d7a055",
"sha256:505738076350a337c1740a31646e1de09a164c62c07db3b996abdc0f9d2e50cf",
"sha256:5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f",
"sha256:5d95cb9f6cced2628f3e4de7e795e98b2659dfcc7176ab4a01a8b48c2c2f488f",
"sha256:7eda4c737637af74bac4b23aa82ea6fbb19002552be85f0b89bc27e3a762d239",
"sha256:801ddaa69659b36abf4694fed5aa9f61d1ecf2daaa6c92541bbbbb775d97b9fe",
"sha256:825aa6d222ce2c2b90d34a0ea31914e141a85edefc07e17342f1d2fdf121c07c",
"sha256:9c215442ff8249d41ff58700e91ef61d74f47dfd431a50253e1a1ca9436b0697",
"sha256:a3d90022f2202bbb14da991f26ca7a30b7e4c62bf0f8bf9825603b22d7e87494",
"sha256:a631fd36a9823638fe700d9225f9698fb59d049c942d322d4c09544dc2115356",
"sha256:a6523a23a205be0fe664b6b8747a5c86d55da960d9586db039eec9f5c269c0e6",
"sha256:a756ecf9f4b9b3ed49a680a649af45a8767ad038de39e6c030919c2f443eb000",
"sha256:b117287a5bdc81f1bac891187275ec7e829e961b8032c9e5ff38b70fd036c78f",
"sha256:ba04f57d1715ca5ff74bb7f8a818bf929a204b3b3c2c2826d1e1cc3b1c13398c",
"sha256:cd878195166723f30865e05d87cbaf9421614501a4bd48792c5ed28f90fd36ca",
"sha256:cee815cc62d136e96cf76771b9d3eb58e0777ec18ea50de5cfcede8a7c429aa8",
"sha256:d1722b7aa4b40cf93ac3c80d3edd48bf93b9208241d166a14ad8e7a20ee1d4f3",
"sha256:d7c1c06246b05529f9984435fc4fa5a545ea26606e7f450bdbe00c153f5aeaad",
"sha256:e9c8066249c040efdda84793a2a669076f92a301ceabe69202446abb4c5c5ef9",
"sha256:f227d7e574d050ff3996049e086e1f18c7bd2d067ef24131e50a1d3fe5831fbc",
"sha256:fc9a12aad714af36cf3ad0275a96a733526571e52710319855628f476dcb144e"
],
"version": "==5.4.1"
},
"pytz": {
"hashes": [
"sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9",
"sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c"
],
"version": "==2018.9"
}
}
}
Heroku错误日志
2019-02-21T03:50:15.022807+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-21T03:50:21.557129+00:00 heroku[web.1]: Starting process with command `gunicorn lusfood.wsgi:application --log-file -`
2019-02-21T03:50:23.307739+00:00 app[web.1]: [2019-02-21 03:50:23 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-02-21T03:50:23.308372+00:00 app[web.1]: [2019-02-21 03:50:23 +0000] [4] [INFO] Listening at: http://0.0.0.0:55813 (4)
2019-02-21T03:50:23.308495+00:00 app[web.1]: [2019-02-21 03:50:23 +0000] [4] [INFO] Using worker: sync
2019-02-21T03:50:23.312130+00:00 app[web.1]: [2019-02-21 03:50:23 +0000] [10] [INFO] Booting worker with pid: 10
2019-02-21T03:50:23.399437+00:00 app[web.1]: [2019-02-21 03:50:23 +0000] [11] [INFO] Booting worker with pid: 11
2019-02-21T03:50:23.758888+00:00 heroku[web.1]: State changed from starting to up
2019-02-21T03:50:24.020060+00:00 app[web.1]: [2019-02-20 20:50:24 -0700] [10] [ERROR] Exception in worker process
2019-02-21T03:50:24.020105+00:00 app[web.1]: Traceback (most recent call last):
2019-02-21T03:50:24.020114+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-02-21T03:50:24.020116+00:00 app[web.1]: worker.init_process()
2019-02-21T03:50:24.020117+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-02-21T03:50:24.020119+00:00 app[web.1]: self.load_wsgi()
2019-02-21T03:50:24.020120+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-02-21T03:50:24.020122+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-02-21T03:50:24.020125+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-02-21T03:50:24.020126+00:00 app[web.1]: self.callable = self.load()
2019-02-21T03:50:24.020127+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-02-21T03:50:24.020129+00:00 app[web.1]: return self.load_wsgiapp()
2019-02-21T03:50:24.020130+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-02-21T03:50:24.020132+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-02-21T03:50:24.020133+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-02-21T03:50:24.020134+00:00 app[web.1]: __import__(module)
2019-02-21T03:50:24.020137+00:00 app[web.1]: File "/app/lusfood/wsgi.py", line 16, in <module>
2019-02-21T03:50:24.020138+00:00 app[web.1]: application = get_wsgi_application()
2019-02-21T03:50:24.020139+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-02-21T03:50:24.020140+00:00 app[web.1]: django.setup(set_prefix=False)
2019-02-21T03:50:24.020141+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2019-02-21T03:50:24.020142+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2019-02-21T03:50:24.020143+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
2019-02-21T03:50:24.020144+00:00 app[web.1]: app_config = AppConfig.create(entry)
2019-02-21T03:50:24.020145+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
2019-02-21T03:50:24.020146+00:00 app[web.1]: module = import_module(entry)
2019-02-21T03:50:24.020147+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2019-02-21T03:50:24.020149+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-02-21T03:50:24.020150+00:00 app[web.1]: ModuleNotFoundError: No module named 'markdownx'
2019-02-21T03:50:24.020295+00:00 app[web.1]: [2019-02-20 20:50:24 -0700] [10] [INFO] Worker exiting (pid: 10)
2019-02-21T03:50:24.020868+00:00 app[web.1]: [2019-02-20 20:50:24 -0700] [11] [ERROR] Exception in worker process
2019-02-21T03:50:24.020870+00:00 app[web.1]: Traceback (most recent call last):
2019-02-21T03:50:24.020871+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-02-21T03:50:24.020872+00:00 app[web.1]: worker.init_process()
2019-02-21T03:50:24.020873+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-02-21T03:50:24.020874+00:00 app[web.1]: self.load_wsgi()
2019-02-21T03:50:24.020875+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-02-21T03:50:24.020876+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-02-21T03:50:24.020877+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-02-21T03:50:24.020878+00:00 app[web.1]: self.callable = self.load()
2019-02-21T03:50:24.020879+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-02-21T03:50:24.020881+00:00 app[web.1]: return self.load_wsgiapp()
2019-02-21T03:50:24.020882+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-02-21T03:50:24.020883+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-02-21T03:50:24.020884+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-02-21T03:50:24.020885+00:00 app[web.1]: __import__(module)
2019-02-21T03:50:24.020886+00:00 app[web.1]: File "/app/lusfood/wsgi.py", line 16, in <module>
2019-02-21T03:50:24.020887+00:00 app[web.1]: application = get_wsgi_application()
2019-02-21T03:50:24.020888+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-02-21T03:50:24.020889+00:00 app[web.1]: django.setup(set_prefix=False)
2019-02-21T03:50:24.020890+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2019-02-21T03:50:24.020892+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2019-02-21T03:50:24.020893+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
2019-02-21T03:50:24.020894+00:00 app[web.1]: app_config = AppConfig.create(entry)
2019-02-21T03:50:24.020895+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
2019-02-21T03:50:24.020896+00:00 app[web.1]: module = import_module(entry)
2019-02-21T03:50:24.020897+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2019-02-21T03:50:24.020898+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-02-21T03:50:24.020899+00:00 app[web.1]: ModuleNotFoundError: No module named 'markdownx'
2019-02-21T03:50:24.021123+00:00 app[web.1]: [2019-02-20 20:50:24 -0700] [11] [INFO] Worker exiting (pid: 11)
2019-02-21T03:50:24.095455+00:00 app[web.1]: [2019-02-21 03:50:24 +0000] [4] [INFO] Shutting down: Master
2019-02-21T03:50:24.095548+00:00 app[web.1]: [2019-02-21 03:50:24 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-02-21T03:50:24.209586+00:00 heroku[web.1]: State changed from up to crashed
2019-02-21T03:50:24.184457+00:00 heroku[web.1]: Process exited with status 3
答案 0 :(得分:2)
似乎您同时拥有Pipfile
和requirements.txt
。在这种情况下,Heroku尝试使用Pipfile
安装软件包,但是您的django-markdownx
在dev-packages
中。
我建议您决定将requirements.txt
或Pipenv
与Pipfile
一起使用。
requirements.txt
,只需删除Pipfile
和Pipfile.lock
。Pipfile
,请不要将dev-package
与pipenv install django-markdownx
一起安装。