【发布时间】:2015-06-13 08:46:10
【问题描述】:
我正在尝试学习本教程:http://tutorial.djangogirls.org/en/index.html
这部分我已经完成了:http://tutorial.djangogirls.org/en/deploy/README.html
我在哪里通过 git 将它推送到 heroku。我熟悉 git 而不是 heroku,虽然我知道 python,但我是 django 初学者。
当我执行命令 git push heroku master 时,我得到了这个阻止应用程序部署的输出。
这是我收到的错误:
(myvenv) $> git push heroku master
Counting objects: 19, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (19/19), 3.81 KiB | 0 bytes/s, done.
Total 19 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing runtime (python-3.4.1)
remote: -----> Installing dependencies with pip
remote: Exception:
remote: Traceback (most recent call last):
remote: File "/app/.heroku/python/lib/python3.4/site-packages/pip- 6.0.6-py3.4.egg/pip/basecommand.py", lin
, in main
remote: status = self.run(options, args)
remote: File "/app/.heroku/python/lib/python3.4/site-packages/pip- 6.0.6-py3.4.egg/pip/commands/install.py"
e 321, in run
remote: finder=finder, options=options, session=session):
remote: File "/app/.heroku/python/lib/python3.4/site-packages/pip-6.0.6-py3.4.egg/pip/req/req_file.py", li
, in parse_requirements
remote: session=session,
remote: File "/app/.heroku/python/lib/python3.4/site-packages/pip- 6.0.6-py3.4.egg/pip/download.py", line 4
n get_file_content
remote: content = f.read()
remote: File "/app/.heroku/python/lib/python3.4/codecs.py", line 313, in decode
remote: (result, consumed) = self._buffer_decode(data, self.errors, final)
remote: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
remote:
remote:
remote: ! Push rejected, failed to compile Python app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to chsdjangoblog.
remote:
To https://git.heroku.com/chsdjangoblog.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/chsdjangoblog.git'
有人知道为什么会这样吗? heroku 似乎很好用,有没有更好的选择/heroku 的最佳用例是什么?我真的只是想解决这个问题,所以我可以继续教程。学习 django 一直是我的目标,因为我厌倦了 Word Press 和 PHP 开发,并且长期以来一直是 Python 爱好者。
当我尝试下一步时出现错误:heroku ps:scale web=1 我得到这个输出:
Scaling dynos... failed
! App mus tbe deployed before dynos can be scaled.
提前致谢。
编辑:
这是我的 requirements.txt:
Django==1.8
dj-database-url==0.3.0
gunicorn==19.3.0
heroku==0.1.4
python-dateutil==1.5
requests==2.6.0
whitenoise==1.0.6
psycopg2==2.5.4`
我尝试保存为 UTF-8、ANSI、UTF-16。给他们所有人的相同信息。我什至在没有复制粘贴的情况下重写了它。为什么无论编码如何,我的第一个字节总是 0xff? heroku 期待什么,有没有办法/工具来检查 txt 文件中的字节?
【问题讨论】:
-
您的 requirements.txt 文件中似乎有一个无效的 UTF8 字符。您可以尝试将其重新保存为 ASCII 吗?
-
同样的错误,即使保存为 ANSI
-
总之我能找到罪魁祸首吗?这显然是依赖项之一。我正在使用带有 ActivePython 的 Python 3.4.1,使用普通的 Python 版本甚至切换到 Linux 会更好吗?
-
不,更改本地使用的 Python 版本不会对推送到 Heroku 时发生的情况产生任何影响。但您可能应该在此处粘贴您的 requirements.txt 文件。