python - Heroku 推送被拒绝,无法编译 Python/django 应用程序 (Python 2.7)

标签 python django deployment heroku python-2.7

我正在做 Heroku 演练:https://devcenter.heroku.com/articles/django#prerequisites对于 python 开发人员,我在尝试运行“git push heroku master”时遇到错误,可以在页面下方大约 1/3 的“部署到 Heroku”部分下找到它。我得到以下回溯:

Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 3.71 KiB, done.
Total 11 (delta 0), reused 0 (delta 0)
-----> Python/Django app detected
-----> Preparing Python interpreter (2.7.2)
-----> Creating Virtualenv (1.8.4)
       Also creating executable in .heroku/venv/bin/python
       Installing distribute...done.
       Installing pip...done.
       Running virtualenv with interpreter /usr/local/bin/python2.7
-----> Installing dependencies using pip (1.1)
       Exception:
       Traceback (most recent call last):
         File "/tmp/build_21leaqqhryfxe/.heroku/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py",
line 104, in main
           status = self.run(options, args)
         File "/tmp/build_21leaqqhryfxe/.heroku/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/install.
py", line 219, in run
           for req in parse_requirements(filename, finder=finder, options=options):
         File "/tmp/build_21leaqqhryfxe/.heroku/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 128
8, in parse_requirements
           req = InstallRequirement.from_line(line, comes_from)
         File "/tmp/build_21leaqqhryfxe/.heroku/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 85,
 in from_line
           elif os.path.isdir(path) and (os.path.sep in name or name.startswith('.')):
         File "/tmp/build_21leaqqhryfxe/.heroku/venv/lib/python2.7/genericpath.py", line 41, in isdir
           st = os.stat(s)
       TypeError: must be encoded string without NULL bytes, not str

       Storing complete log in /app/.pip/pip.log
 !     Heroku push rejected, failed to compile Python/django app

To git@heroku.com:stark-fortress-9694.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:stark-fortress-9694.git'

到目前为止,其他一切都已成功运行。有什么见解吗?我对此完全陌生。提前感谢您的帮助。

这是 requirements.txt 的样子:

Django==1.4.3
distribute==0.6.31
dj-database-url==0.2.1
psycopg2==2.4.5

最佳答案

我认为问题出在您的 requirements.txt 文件的编码中。可能您在不知不觉中将其保存为 Unicode 格式。您应该将其保存为 ANSI 格式。有关详细信息,请参阅此链接:http://georgik.sinusgear.com/2012/08/20/problems-with-deploying-heroku-django-app-from-windows/

关于python - Heroku 推送被拒绝,无法编译 Python/django 应用程序 (Python 2.7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13896736/

相关文章:

python - 如何刷新 flask 网页?

java - Java JRE 的安装基础?

node.js - Google Cloud Platform 应用部署导致 502 服务器错误

Glassfish war 生命周期问题

python - "Cannot access setup.py: No such file or directory"- 无法运行任何 .py 文件?

Python——2.7 中没有的东西是 3.1 中的什么?很多东西都被向后移植了,什么不是?

django - 了解 Django 模型继承怪癖

django - 使用 django-mptt 制作 FeinCMS 页面树的副本更改子顺序

Django 管理员 : How to customize one field in fieldsets?

python - 如何在 Keras Lambda 层中使用 OpenCV 函数?