9

I am trying to install a python library on macOS following through these instructions.

However I get an error every time I run this command : pip install --target=. Alfred-Workflow

And I always get this error for running it :

pip install --target=. Alfred-Workflow       
Collecting Alfred-Workflow
Installing collected packages: Alfred-Workflow
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "/usr/local/lib/python2.7/site-packages/pip/locations.py", line 153, in distutils_scheme
    i.finalize_options()
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 264, in finalize_options
    "must supply either home or prefix/exec-prefix -- not both"
DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both

I tried googling and searching for this but still can't figure it out. Thank you for any help.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Nikita
  • 449
  • 1
  • 7
  • 23
  • Try [removing the equals sign `=`](https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-t) - `pip install -t . Alfred-Workflow` – MattDMo Jan 13 '17 at 19:04
  • Doesn't work. Gives a similar message : http://i.imgur.com/hu5q9qp.png – Nikita Jan 13 '17 at 19:48
  • Possible duplicate of [DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both](http://stackoverflow.com/questions/24257803/distutilsoptionerror-must-supply-either-home-or-prefix-exec-prefix-not-both) – hansaplast Jan 13 '17 at 20:40

2 Answers2

17

This question answers that (I found it when googling for the last line of your error message).

First I also got the same error message as you did, but after doing this:

$ echo "[install]
prefix=" > ~/.pydistutils.cfg

It works:

$ pip install --target=. Alfred-Workflow
Collecting Alfred-Workflow
Installing collected packages: Alfred-Workflow
Successfully installed Alfred-Workflow-1.24

Important note: it breaks normal pip install commands, so you need to rm ~/.pydistutils.cfg afterward.

Community
  • 1
  • 1
hansaplast
  • 11,007
  • 2
  • 61
  • 75
  • I did. In the question you linked, it says "If you create ~/.pydistutils.cfg file with "empty prefix" instruction it will fix this problem but it will break normal pip operations.". Is my pip broken now too? – Nikita Jan 14 '17 at 16:26
  • oh yes, it does! Thanks for pointing out. I added a note to the answer – hansaplast Jan 14 '17 at 16:31
  • 3
    Is there a way to fix this issue without breaking normal pip install and having to rm ~/.pydistutils.cfg every time after running this command? – Nikita Jan 14 '17 at 16:33
  • apparently not, at least according to the discussion at the question I linked. As far as I understand it's a homebrew issue, so you could reinstall python without homebrew, I would expect that this issue is fixed this way – hansaplast Jan 14 '17 at 16:39
5

I have a similar error installing python modules using pip with -t(--target) option.

The pip log show the next message:

Complete output from command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-LvB_CW/xlrd/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-UNJizV-record/install-record.txt --single-version-externally-managed --compile --user --home=/tmp/tmphjBN23

and the next error:

can't combine user with prefix, exec_prefix/home, or install_(plat)base

Reading about alternate installation on python docs I see the next info

Note that the various alternate installation schemes are mutually exclusive: you can pass --user, or --home, or --prefix and --exec-prefix, or --install-base and --install-platbase, but you can’t mix from these groups.

So the command executed by pip has two mutually exclusive schemes --user and --home (i think it could be a bug on pip).

I use the --system option to avoid the error, eliminating the --user flag on the setup command.

pip install -t path_to_dir module_name --system

I don't known the aditional implications of this usage, but i think it's better than modifing the config file that messed up with normal installations.

PD: I use ubuntu 15.10 with pip 1.5.6

pipelog
  • 354
  • 3
  • 6