我一直在尝试将一个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)
他们的requirements.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编码。有关此错误的其他线程通常通过转义某些字符或更改编码来解决。但我找不到可供使用的替代编码。
有没有任何空字节保存要求的技巧?还是有其他已知的修复方法吗?
修改更新:
使用-vvv max verbose模式运行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
答案 0 :(得分:0)
尝试使用Iron docker图像在Mac上运行pip install
时遇到了同样的问题。在尝试修复它之后,我将问题跟踪到Docker Toolbox和vboxfs。他们没有正确同步主机文件系统更改。为了解决这个问题,我在docker工具箱VM中运行了:
sync; echo 3 > /proc/sys/vm/drop_caches
sync
调用会同步任何挂起的写入磁盘。第二个命令告诉内核清除文件系统缓存。
一旦我这样做,pip install
工作正常。
答案 1 :(得分:0)
在Windows和Mac OS上,Docker Daemon在虚拟机上运行。
尝试输入虚拟机并在其中运行Docker命令。解决此问题的一种可能的方法是避免在主机上运行Docker命令。
提醒一下,Iron.io的支持可以通过电话,电子邮件或chat获得其他问题。