I had pip failing on me while trying to install a lot of requirements from within a custum develop command inside a setup.py. It failed on python 3.x (2.x was fine) with the message:
ValueError: underlying buffer has been detached
The solution was to instead of calling pip from inside the code like
import pip; pip.main([...])
just call it from the commandline like:
def pip_install(what):
os.system("pip install " + what)