点子安装--target =。 Alfred-Workflow给出了一个错误

时间:2017-01-13 18:11:23

标签: python macos alfred

我正在尝试通过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

我尝试使用Google搜索并搜索此内容但仍无法弄明白。谢谢你的帮助。

2 个答案:

答案 0 :(得分:15)

This回答问题(我在Google上搜索错误信息的最后一行时发现了这一点。)

首先,我也收到了与您相同的错误消息,但在执行此操作后:

$ 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之后。

答案 1 :(得分:3)

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

点子日志显示下一条消息:

  

从命令/ usr / bin / python -c&#34完成输出;导入setuptools,tokenize; 文件 =' / tmp / pip-build-LvB_CW / xlrd / setup。 py&#39 ;; exec(编译(getattr(tokenize,'打开',打开)(文件)。read()。replace(' \ r \ n&# 39;,' \ n'),文件,' exec'))" install --record /tmp/pip-UNJizV-record/install-record.txt --single-version-external-managed --compile --user --home = / tmp / tmphjBN23

和下一个错误:

  

无法将用户与前缀,exec_prefix / home或install_(plat)base相结合

在python docs上阅读alternate installation我看到了下一个信息

  

请注意,各种备用安装方案是互斥的:您可以传递--user或--home,或--prefix和--exec-prefix,或--install-base和--install-platbase,但你不能混在一起。

所以pip执行的命令有两个互斥的方案 - 用户 - home (我认为这可能是pip上的一个bug)。

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

  

pip install -t path_to_dir module_name --system

我不知道这种用法的附加含义,但我认为它比修改与正常安装相混淆的配置文件更好。

PD:我使用ubuntu 15.10和pip 1.5.6

相关问题