Fix Python – DistutilsOptionError: must supply either home or prefix/exec-prefix — not both

Question

Asked By – Arthur Kim

I’ve been usually installed python packages through pip.

For Google App Engine, I need to install packages to another target directory.

I’ve tried:

pip install -I flask-restful –target ./lib

but it fails with:

must supply either home or prefix/exec-prefix — not both

How can I get this to work?

Now we will see solution for issue: DistutilsOptionError: must supply either home or prefix/exec-prefix — not both


Answer

Are you using OS X and Homebrew? The Homebrew python page https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md calls out a known issue with pip and a work around.

Worked for me.

You can make this “empty prefix” the default by adding a
~/.pydistutils.cfg file with the following contents:

[install]
prefix=

Edit: The Homebrew page was later changed to recommend passing --prefix on the command line, as discussed in the comments below. Here is the last version which contained that text. Unfortunately this only works for sdists, not wheels.

The issue was reported to pip, which later fixed it for --user. That’s probably why the section has now been removed from the Homebrew page. However, the problem still occurs when using --target as in the question above.

This question is answered By – ayvazj

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0