在OS X 10.8 macports安装后,python pip无法处理requirements.txt

时间:2012-12-23 00:37:16

标签: python macos pip macports requirements.txt

最近购买了一台新Mac,并为Python和iOS开发设置了它。 Python工作正常 - 特别是pip'ing git repos有很多要求.txt依赖关系UNTIL我安装了Xcode,macports和Apple的命令行工具。

现在pip适用于单独安装(例如,pip install twilio),但每当我针对requirements.txt文件运行pip时,它都会失败(有或没有sudo):

pip install ./requirements.txt
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 225, in run
    InstallRequirement.from_line(name, None))
  File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 118, in from_line
    return cls(req, comes_from, url=url)
  File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 43, in __init__
    req = pkg_resources.Requirement.parse(req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2510, in parse
    reqs = list(parse_requirements(s))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2436, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2404, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', './requirements.txt', 'at', '/requirements.txt')

我的$PATH值为

/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

这看起来不同于“OS X 10.8升级后破解的Python点”线程。我很想知道macports在查看/System/Libary~/Library之间是否存在冲突。

有什么想法吗?

1 个答案:

答案 0 :(得分:4)

如果要通过需求文件安装软件包,则需要--requirement/-r选项:

$ pip install -r requirements.txt