我一直在尝试将 python 脚本部署到 Iron.io。他们建议在上传之前使用 docker 在本地进行测试。
我已经完成了他们提供的 docker/iron 教程,没有错误。
所以我开始从他们的示例 repo 中修改提供的 requirements.txt以启动我自己的项目,但是每当我尝试在本地安装包时,我都会收到 TypeError。
我的点子是版本:
pip 7.1.2 from /Library/Python/2.7/site-packages (python 2.7)
他们的要求.txt
iron-mq>=0.5
iron-worker>=1.3.1
我的要求.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 进行编码。有关此错误的其他线程通常通过转义某些字符或更改编码来解决。但我找不到可以使用的替代编码。
在没有任何空字节的情况下保存需求是否有技巧?还是有另一个已知的修复?
编辑更新:
使用 pip 的 -vvv max 详细模式运行
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