点安装 --target=. Alfred-Workflow 报错

Pip install --target=. Alfred-Workflow gives an error

我正尝试在 these instructions 之后在 macOS 上安装 python 库。

但是我每次 运行 这个命令都会出错:pip install --target=. Alfred-Workflow

而且我总是 运行 遇到这个错误:

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

我尝试使用谷歌搜索并搜索此内容,但仍然无法弄清楚。感谢您的帮助。

This 问题回答了(我在谷歌搜索错误消息的最后一行时发现了它)。

首先我也得到了和你一样的错误信息,但是在这样做之后:

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

有效:

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

重要说明:它破坏了正常的pip install命令,所以你需要rm ~/.pydistutils.cfg之后。

我在使用带有 -t(--target) 选项的 pip 安装 python 模块时遇到了类似的错误。

pip 日志显示下一条消息:

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

和下一个错误:

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

在 python 文档上阅读关于 alternate installation 我看到了下一个信息

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.

所以pip执行的命令有两个互斥方案--user--home(我觉得可能是pip 上的错误)。

我使用 --system 选项来避免错误,消除了安装命令中的 --user 标志。

pip install -t path_to_dir module_name --system

我不知道这种用法的其他含义,但我认为这比修改扰乱正常安装的配置文件要好。

PD:我使用 ubuntu 15.10 和 pip 1.5.6