4

Recently bought a new Mac and was setting it up for both Python and iOS development. Python was working fine--especially pip'ing git repos with lots of requirements.txt dependencies UNTIL I installed Xcode, macports and Apple's command line tools.

Now pip works fine for individual install (e.g., pip install twilio), but whenever I run pip against a requirements.txt file it fails (with or without 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')

My $PATH value is

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

This looks different than the "Python pip broken after OS X 10.8 upgrade" thread. I am wonder if macports created a conflict between looking in /System/Libary and ~/Library.

Any ideas?

Brett Gregson
  • 5,867
  • 3
  • 42
  • 60
user1924333
  • 41
  • 1
  • 2

2 Answers2

5

If you want to install packages through a requirements file, you need the --requirement/-r option:

$ pip install -r requirements.txt
Hugo Lopes Tavares
  • 28,528
  • 5
  • 47
  • 45
0

$ pip3 install -r requirements.txt

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 21 '21 at 23:04