您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

将Django / Python 3.4部署到Heroku

5b51 2022/1/14 8:23:50 python 字数 5209 阅读 613 来源 www.jb51.cc/python

我正在尝试使用Django / Heroku入门教程部署我的第一个使用Django / Heroku的示例应用程序.我的工具:Python 3.4和Windows 7 PowerShell.我的挑战:部署到Heroku失败了,我不知道为什么.在我第一次“git push”时,我看到默认情况下使用了python-2.7.0.然后我在app根目录中添加了runt

概述

我正在尝试使用Django / Heroku入门教程部署我的第一个使用Django / Heroku的示例应用程序.

我的工具:Python 3.4和Windows 7 PowerShell.

我的挑战:部署到Heroku失败了,我不知道为什么.在我第一次“git push”时,我看到认情况下使用了python-2.7.0.然后我在app根目录中添加了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

这里我的procfile(btw:gunicorn似乎是一个Unix“唯一”命令,不适用于Windows; read here):

web: gunicorn mytodo.wsgi

Heroku教程没有提到setup.py文件,but it seems that one is necessary,所以我只是复制了一个模板….不是我喜欢的解决方案,但我不知道还能做什么.

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文件错误.

任何帮助表示赞赏.谢谢!

为了解决这个问题,我在记事本中打开了requirements.txt,转到了File->另存为,并在再次保存之前将编码设置为ANSI.在git-commit新的requirements.txt之后,我能够运行git push heroku master并且它按预期工作.

总结

以上是编程之家为你收集整理的将Django / Python 3.4部署到Heroku全部内容,希望文章能够帮你解决将Django / Python 3.4部署到Heroku所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶