3

最近买了一台新的 Mac,正在为 Python 和 iOS 开发设置它。Python 运行良好——尤其是 pip'ing git repos 与很多 requirements.txt 依赖项,直到我安装了 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 pip 损坏”线程不同。我想知道 macports 是否在查看/System/Libary~/Library.

有任何想法吗?

4

2 回答 2

5

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

$ pip install -r requirements.txt
于 2012-12-29T23:49:23.010 回答
0

$ pip3 install -r requirements.txt

于 2021-09-21T22:53:00.023 回答