Python Pip安装——目标=。Alfred工作流给出了一个错误

Python Pip安装——目标=。Alfred工作流给出了一个错误,python,macos,alfred,Python,Macos,Alfred,我正试图在macOS上安装一个python库 但是,每次运行此命令时都会出现一个错误:pip install--target=。Alfred工作流 运行它时,我总是会遇到以下错误: pip install --target=. Alfred-Workflow Collecting Alfred-Workflow Installing collected packages: Alfred-Workflow Exception: Traceback (most recent call

我正试图在macOS上安装一个python库

但是,每次运行此命令时都会出现一个错误:
pip install--target=。Alfred工作流

运行它时,我总是会遇到以下错误:

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
我试着在谷歌上搜索这个,但还是找不出来。谢谢您的帮助。

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

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

$ 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日志显示下一条消息:

从命令/usr/bin/python-c“导入setuptools,tokenize;文件=”/tmp/pip-build-LvB_CW/xlrd/setup.py';exec(编译(getattr(tokenize,'open',open)(文件).read().replace('\r\n','\n'),文件,'exec'))install--record/tmp/pip UNJizV record/install-record.txt--外部管理的单一版本--编译--user--home=/tmp/tmphjBN23

下一个错误是:

无法将用户与前缀、exec\u prefix/home或install\u(plat)base组合

在阅读python文档时,我看到了下面的信息

请注意,各种备选安装方案是互斥的:您可以传递--user,或--home,或--prefix和--exec prefix,或--install base和--install platbase,但不能从这些组中混合使用

因此,pip执行的命令有两个相互排斥的方案--user--home(我认为这可能是pip上的一个bug)

我使用--system选项来避免错误,消除setup命令上的--user标志

pip安装-t路径\u到\u目录模块\u名称--系统

我不知道这种用法的传统含义,但我认为它比修改配置文件要好,因为它会破坏正常的安装


PD:我将ubuntu 15.10与PIP1.5.6一起使用。Alfred工作流不起作用。给出了一个类似的信息:我做的可能重复。在您链接的问题中,它说“如果您使用“空前缀”指令创建~/.pydistutils.cfg文件,它将修复此问题,但会中断正常的pip操作。”。我的皮普现在也坏了吗?哦,是的,坏了!谢谢你指出。我在回答中添加了一条注释:有没有办法在不破坏正常pip安装的情况下修复此问题,并且在运行此命令后每次都必须使用rm~/.pydistutils.cfg?显然没有,至少根据我链接的问题的讨论,没有。据我所知,这是一个自制的问题,因此您可以在不使用自制的情况下重新安装python,我希望这个问题可以通过这种方式得到解决,在添加--system标志后,它可以正常工作。非常感谢。