我正在尝试在Ubuntu中使用“两勺Django 1.6”项目结构在Heroku中部署Django Web应用程序。
在执行 heroku create 后,我运行 git push heroku master ,并在最后获得输出。
我广泛搜索,我知道错误就是这个
TypeError: must be encoded string without NULL bytes, not str
它是由于需求文件中的某些编码或稀有字符引起的。我的问题是我尝试使用较少的依赖项进行保存并更改文件中的编码并且什么也没做(我不知道Heroku的有效编码,所以我对此视而不见)。
我正在寻找一种找到空字符的方法,即使在命令行中使用 cat -e ,但我找不到任何东西。 我正在寻找一种方法来查找编码问题或错误的依赖 。
先谢谢你。
编辑:我试着做点子
install -r <fileName>.txt
我的几个要求txt文件。所有装置都很好。我也尝试使用主要的requirements.txt(一个空文件)中的所有注释来执行git push heroku master并且它一直给出相同的错误。也许heroku没有选择requirements.txt文件???
我尝试从命令行重新创建文件并手动输入相同的内容(而不是复制粘贴)。同样的错误不断出现。 : - (
我的要求文件是:
requirements.txt (在项目的根本):
# This file is here because many Platforms as a Service look for
# requirements.txt in the root directory of a project.
-r requirements/production.txt
要求/ production.txt :
# Pro-tip: Try not to put anything here. There should be no dependency in
# production that isn't in development.
-r base.txt
gunicorn==18.0
和 requirements / base.txt :
Django==1.7
psycopg2==2.6
sqlparse==0.1.15
django-debug-toolbar==1.3.0
html5lib==0.999
Pillow==2.8.1
PyPDF2==1.24
reportlab==3.1.44
six==1.9.0
xhtml2pdf==0.0.6
输出:
Pushing to https://git.heroku.com/tranquil-cliffs-3699.git
POST git-receive-pack (chunked)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing runtime (python-2.7.10)
remote: -----> Installing dependencies with pip
remote: Exception:
remote: Traceback (most recent call last):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/basecommand.py", line 223, in main
remote: status = self.run(options, args)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/commands/install.py", line 268, in run
remote: wheel_cache
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/basecommand.py", line 287, in populate_requirement_set
remote: wheel_cache=wheel_cache):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py", line 86, in parse_requirements
remote: for req in req_iter:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py", line 161, in process_line
remote: for req in parser:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py", line 86, in parse_requirements
remote: for req in req_iter:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py", line 161, in process_line
remote: for req in parser:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py", line 86, in parse_requirements
remote: for req in req_iter:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py", line 130, in process_line
remote: wheel_cache=wheel_cache
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_install.py", line 162, in from_line
remote: if (os.path.isdir(p) and
remote: File "/app/.heroku/python/lib/python2.7/genericpath.py", line 49, in isdir[K
remote: st = os.stat(s)
remote: TypeError: must be encoded string without NULL bytes, not str
remote:
remote:
remote: ! Push rejected, failed to compile Python app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to tranquil-cliffs-3699.
remote:
To https://git.heroku.com/tranquil-cliffs-3699.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/tranquil-cliffs-3699.git'
答案 0 :(得分:1)
这完全是我的错。超级新手愚蠢的错误。每次编辑后我都没有进行 git commit ,所以我总是向Heroku推送相同的错误文件。
现在我终于意识到了,当推送错误时已经改变为另一个错误。
非常感谢你的帮助,很抱歉让你失去了时间。