我正在尝试使用 Django/Heroku 入门教程使用 Django/Heroku 部署我的第一个示例应用程序。
我的工具:Python 3.4 和 Windows 7 PowerShell。
我的挑战:部署到 Heroku 失败,我不知道为什么。在我第一次“git Push”时,我看到默认使用 python-2.7.0。然后我添加了一个runtime.txt
应用程序根目录中的 (python-3.4.0) 文件。
这是我跑步时发生的情况git push heroku master
-----> Python app detected
-----> Preparing Python runtime (python-3.4.0)
-----> Installing Setuptools (2.1)
-----> Installing Pip (1.5.4)
-----> Installing dependencies using Pip (1.5.4)
Exception:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.4/site-packages/pip-1.5.4-py3.4.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/app/.heroku/python/lib/python3.4/site-packages/pip-1.5.4-py3.4.egg/pip/commands/install.py", line 262, in run
for req in parse_requirements(filename, finder=finder, options=options, session=session):
File "/app/.heroku/python/lib/python3.4/site-packages/pip-1.5.4-py3.4.egg/pip/req.py", line 1546, in parse_requirements
session=session,
File "/app/.heroku/python/lib/python3.4/site-packages/pip-1.5.4-py3.4.egg/pip/download.py", line 275, in get_file_content
content = f.read()
File "/app/.heroku/python/lib/python3.4/codecs.py", line 313, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Storing debug log for failure in /app/.pip/pip.log
! Push rejected, failed to compile Python app
这里是我的内容requirements.txt
文件(使用创建pip freeze > requirements.txt
)
Django==1.6.2
dj-database-url==0.3.0
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.2
pystache==0.5.3
static==1.0.2
Here my Procfile
(顺便说一句:gunicorn 似乎是 Unix 的“唯一”命令,不适用于 Windows;在这里读 http://www.swarley.me.uk/blog/2014/02/24/create-a-django-development-environment-on-64-bit-windows-for-heroku-deployment/):
web: gunicorn mytodo.wsgi
Heroku 教程没有提到setup.py
file, 但似乎有必要 https://github.com/heroku/heroku-buildpack-python/blob/master/bin/detect,所以我只是复制了一个模板......这不是我首选的解决方案,但我不知道还能做什么。
setup(
name='mysite',
version='0.1.0',
install_requires=[], # Don't put anything here, just use requirements.txt
packages=['mysite'],
package_dir={'mysite': 'src/mysite'},
)
可能发生了什么:
- unicode 错误消息可能源于Procfile
。我在网上的某个地方读到它必须是 ASCII 文件,但我不确定如何声明它,因为 Procfile 没有文件结尾。
- setup.py 文件错误。
任何帮助表示赞赏。谢谢!