gpt4 book ai didi

python - python TypeError:必须是不带NULL字节的编码字符串,而不是str-docker iron requirements.txt

转载 作者:行者123 更新时间:2023-12-02 18:42:02 25 4
gpt4 key购买 nike

我一直在尝试将Python脚本部署到Iron.io。他们建议在上传之前使用docker在本地进行测试。

我已经完成their provided docker/iron tutorial,没有错误。

因此,我开始从其示例存储库中修改the provided requirements.txt以启动自己的项目,但是每当我尝试在本地安装软件包时,都会收到TypeError。

我的点是版本:

pip 7.1.2 from /Library/Python/2.7/site-packages (python 2.7)

他们的要求
iron-mq>=0.5
iron-worker>=1.3.1

我的requirements.txt
iron-mq>=0.5
iron-worker>=1.3.1
beautifulsoup4
html5lib

终端命令:
$ docker run --rm -v "$PWD":/worker -w /worker iron/python:2-dev pip install -t packages -r requirements.txt

错误:
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 282, in run
wheel_cache
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 291, in populate_requirement_set
wheel_cache=wheel_cache):
File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 89, in parse_requirements
for req in req_iter:
File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 137, in process_line
isolated=isolated, options=req_options, wheel_cache=wheel_cache
File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 168, in from_line
if (os.path.isdir(p) and
File "/usr/lib/python2.7/genericpath.py", line 49, in isdir
st = os.stat(s)
TypeError: must be encoded string without NULL bytes, not str

我在OSX上使用Sublime,并使用UTF-8编码。通常,通过转义某些字符或更改编码来解决与该错误有关的其他线程。但是我找不到使用的替代编码。

有没有技巧可以保存没有空字节的需求?还是有另一个已知的解决方法?

编辑更新:

使用-vvv max详细模式运行pip
docker run --rm -v "$PWD":/worker -w /worker iron/python:2-dev pip install -vvv -t packages -r requirements.txt

回到
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 282, in run
wheel_cache
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 291, in populate_requirement_set
wheel_cache=wheel_cache):
File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 89, in parse_requirements
for req in req_iter:
File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 137, in process_line
isolated=isolated, options=req_options, wheel_cache=wheel_cache
File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 168, in from_line
if (os.path.isdir(p) and
File "/usr/lib/python2.7/genericpath.py", line 49, in isdir
st = os.stat(s)
TypeError: must be encoded string without NULL bytes, not str
Starting new HTTPS connection (1): pypi.python.org
"GET /pypi/pip/json HTTP/1.1" 200 50975

唯一的新输出是底部的两行。

运行iconv以识别任何流氓字符只会返回txt文件的内容。
iconv -t UTF-8 requirements.txt

iron-mq>=0.5
iron-worker>=1.3.1
beautifulsoup4==4.4.1

最佳答案

尝试使用Iron docker镜像在Mac上运行pip install时遇到了同样的麻烦。在尝试了许多修复方法后,我将问题归结为Docker Toolbox和vboxfs。他们没有正确同步主机文件系统更改。要修复它,我在docker工具箱VM中运行:
sync; echo 3 > /proc/sys/vm/drop_cachessync调用将所有未完成的写入同步到磁盘。第二条命令告诉内核清除文件系统缓存。

一旦我做到了,我的pip install可以正常工作。

关于python - python TypeError:必须是不带NULL字节的编码字符串,而不是str-docker iron requirements.txt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34703094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com