本文介绍了Heroku:不带NULL字符串的字符串,带有多个需求文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在执行 heroku之后,我正在尝试从Ubuntu中部署一个Django Web应用程序。创建,我运行 git push heroku master ,我得到结尾附加的输出。 我广泛浏览, m知道错误是这个 TypeError:必须是不带NULL字节的编码字符串,而不是str ,这是因为需求文件中的某些编码或罕见字符。我的问题是,我尝试保存更少的依赖性和更改文件中的编码,并且没有实现(我不知道Heroku的有效编码,所以我是盲目的)。 我正在寻找一种查找空字符的方法,即使在命令行中使用 cat -e ,但我找不到任何东西。 我正在要求找到编码问题或错误的依赖关系 。 谢谢高级 编辑:我尝试了点数 install -r< fileName> .txt 的我的要求txt文件。所有的安装都很好。我也尝试做git推英雄主人,所有的注释在主要的.txt(一个空的文件),它不断给出相同的错误。我可以尝试从命令行重新创建文件并手动输入相同的内容(不是复制粘贴) 。同样的错误不断出现。 : - ( 文件和输出: 我的需求文件是: requirements.txt (在项目的根源): #此文件在这里是因为许多平台即服务在项目根目录中查找#requirements.txt -r要求/ production.txt 要求/ production.txt : #提示:尽量不要把任何东西放在这里,在#开发 -r base.txt gunicorn == 18.0 和要求/ base.txt : Django == 1.7 psycopg2 = = 2.6 sqlparse == 0.1.15 django-debug-toolbar == 1.3.0 html5lib == 0.999 枕头= 2.8.1 PyPDF2 = = 1.24 reportlab == 3.1.44 six == 1.9.0 xhtml2pdf == 0.0.6 输出: 推送到https://git.heroku.com/tranquil -cliffs-3699.git POST git-receive-pack(chunked) remote:压缩源文件...完成。 remote:构建源: remote: remote:----->检测到Python应用程序 remote:----->安装运行时(python-2.7.10) remote:----->使用pip 安装依赖关系remote:异常: remote:Traceback(最近的最后一次调用): remote:File/app/.heroku/python/lib/python2.7/site- package / pip-7.0.1-py2.7.egg / pip / basecommand.py,第223行,主要 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,第268行,运行 remote: wheel_cache remote:文件/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/basecommand.py,第287行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,第86行,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,第161行,process_line remote:for解析器中的req: remote:文件/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_file.py,第86行,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 parq中的req: remote:File/app/.heroku/python/lib/python2.7/site-packages/pip-7.0。 1-py2.7.egg / pip / req / req_file.py,第86行,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,第130行,process_line remote:wheel_cache = wheel_cache remote:文件/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/req/req_install.py,第162行,from_line remote:if(os.path.isdir(p)和 remote:文件/app/.heroku/python/lib/python2.7/genericpath.py,第49行在isdir中[K remote:st = os.stat( s) remote:TypeError:必须是不带NULL字节的编码字符串,而不是str remote: remote: remote:!推送拒绝,无法编译Python应用程序 remote: remote:验证部署... remote: remote:!推送拒绝到宁静的悬崖-3699。 remote: To https://git.heroku.com/tranquil-cliffs-3699.git ! [远程拒绝]主 - > master(预收款钩子拒绝)错误:无法推一些参考https://git.heroku.com/tranquil-cliffs-3699.git 解决方案这是我的错。超新星愚蠢的错误。每次编辑后,我并没有提供 git commit ,所以我总是把相同的错误文件推送到Heroku。 现在我终于意识到了 非常感谢您的帮助,感到遗憾的是让您失去了时间。 I'm trying to deploy a Django web application in Heroku from Ubuntu following the "Two scoops of Django 1.6" project structure.After doing heroku create, I run git push heroku master and I get the output attached at the end.I googled extensively and I'm aware that the error is thisTypeError: must be encoded string without NULL bytes, not strand it is caused because some encoding or rare characters in requirements files. My problem is that I tried saving with less dependencies and changing encodings in the files and achieved nothing (I don't know the valid encodings for Heroku, so I'm blind at this).I'm looking for a way of finding the null characters, even with cat -e at the command line, but I can't find anything. I'm asking for a way for finding the encoding problem or the wrong dependency.Thank you in advanced.EDIT: I tried doing pip install -r <fileName>.txt with several of my requirements txt files. All the installations were fine. I also tried doing the git push heroku master with all commented in the main requirements.txt (an empty file) and it keeps giving the same error. Maybe heroku is not picking the requirements.txt file???I tried re-creating the files from command line and typing manually the same content (not copy-paste). The same error keeps appearing. :-(Files and output:My requirements files are:requirements.txt (at the very root of the project):# This file is here because many Platforms as a Service look for# requirements.txt in the root directory of a project.-r requirements/production.txtrequirements/production.txt:# Pro-tip: Try not to put anything here. There should be no dependency in# production that isn't in development.-r base.txtgunicorn==18.0and requirements/base.txt:Django==1.7psycopg2==2.6sqlparse==0.1.15django-debug-toolbar==1.3.0html5lib==0.999Pillow==2.8.1PyPDF2==1.24reportlab==3.1.44six==1.9.0xhtml2pdf==0.0.6the output:Pushing to https://git.heroku.com/tranquil-cliffs-3699.gitPOST git-receive-pack (chunked)remote: Compressing source files... done.remote: Building source:remote: remote: -----> Python app detectedremote: -----> Installing runtime (python-2.7.10)remote: -----> Installing dependencies with pipremote: 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 mainremote: 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 runremote: wheel_cacheremote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-7.0.1-py2.7.egg/pip/basecommand.py", line 287, in populate_requirement_setremote: 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_requirementsremote: 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_lineremote: 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_requirementsremote: 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_lineremote: 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_requirementsremote: 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_lineremote: wheel_cache=wheel_cacheremote: 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_lineremote: if (os.path.isdir(p) andremote: File "/app/.heroku/python/lib/python2.7/genericpath.py", line 49, in isdir[Kremote: st = os.stat(s)remote: TypeError: must be encoded string without NULL bytes, not strremote: remote: remote: ! Push rejected, failed to compile Python appremote: 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' 解决方案 It was all my fault. Super-newbie stupid error. I was not making git commit after each edit, so I was pushing always the same wrong files to Heroku.Now I finally realized, and when pushing the error has changed to another one.Thanks a lot for your help and sorry for making you lose your time. 这篇关于Heroku:不带NULL字符串的字符串,带有多个需求文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-22 00:35