Django 错误部署到 heroku 要求

oos*_*enb 1 python django heroku

我正在尝试将我的 django 应用程序部署到 heroku。我有一个虚拟环境(当然)。我已经正确设置了 procfile、setup.py 和 runtime.txt。它在本地开发服务器上完美运行,但是当我推送到 heroku 时,它会在需求文件中出现某种错误。

这是推送到 heroku 后的第三次回溯。我前两次更改了 procfile,然后它只给出了 procfile 的错误。现在 procfile 错误消失了,我对此有某种错误。

追溯:

    Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 309 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/python
remote: -----> Python app detected
remote: -----> Uninstalling stale dependencies
remote: Invalid requirement: 'There was a problem loading the given requirements files.'
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/req/req_install.py", line 77, in
 __init__
remote:     req = pkg_resources.Requirement.parse(req)
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/pkg_resources/__init__.p
y", line 3036, in parse
remote:     req, = parse_requirements(s)
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/pkg_resources/__init__.p
y", line 2980, in parse_requirements
remote:     "version spec")
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/pkg_resources/__init__.p
y", line 2945, in scan_list
remote:     raise RequirementParseError(msg, line, "at", line[p:])
remote: pip._vendor.pkg_resources.RequirementParseError: Expected version spec in There was a problem loading the given
requirements files. at  was a problem loading the given requirements files.
remote:
remote: You are using pip version 8.1.1, however version 8.1.2 is available.
remote: You should consider upgrading via the 'pip install --upgrade pip' command.
remote:      $ pip install -r requirements.txt
remote:
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web, worker
remote:
remote: -----> Compressing...
remote:        Done: 60.3M
remote: -----> Launching...
remote:        Released v6
remote:        https://calm-caverns-85777.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/calm-caverns-85777.git
   b1b06b0..d6b1a95  master -> master
Run Code Online (Sandbox Code Playgroud)

简介:

web: gunicorn blog.wsgi
worker: python worker.py
Run Code Online (Sandbox Code Playgroud)

要求.txt:

dj-database-url==0.4.1
Django==1.9.7
django-crispy-forms==1.6.0
django-markdown-deux==1.0.5
django-pagedown==0.1.1
gunicorn==19.6.0
markdown2==2.3.1
Pillow==3.2.0
whitenoise==3.2
Run Code Online (Sandbox Code Playgroud)

运行时.txt:

python-3.5.1
Run Code Online (Sandbox Code Playgroud)

我可以从 requirements.txt 文件本地安装依赖项,另一件事是当我尝试更新 pip 时,它说它已经是最新的。我的运行时环境设置为 python 3.5.1。该应用程序在部署时崩溃,我假设这是由于回溯错误。我能做些什么来解决这个问题?

Jes*_*ith 5

requirements.txt 文件是如何创建的?它是否可能已损坏或不是纯文本或其中包含不可打印的字符?

我建议删除 requirements.txt 并根据 pip freeze 干净地生成它。

如果您使用的是 Windows Powershell,编码问题可能会影响您。建议的解决方案是:

pip freeze | Out-File -Encoding ASCII requirements.txt
Run Code Online (Sandbox Code Playgroud)