Nik*_*oev 7 python macos alfred
我试图通过这些说明在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
Run Code Online (Sandbox Code Playgroud)
我试着谷歌搜索并搜索这个,但仍然无法弄明白.感谢您的任何帮助.
han*_*ast 17
这个问题回答了(我在谷歌搜索你的错误信息的最后一行时发现了它).
首先,我也得到了与您相同的错误消息,但在执行此操作后:
$ echo "[install]
prefix=" > ~/.pydistutils.cfg
Run Code Online (Sandbox Code Playgroud)
有用:
$ pip install --target=. Alfred-Workflow
Collecting Alfred-Workflow
Installing collected packages: Alfred-Workflow
Successfully installed Alfred-Workflow-1.24
Run Code Online (Sandbox Code Playgroud)
重要说明:它会破坏正常pip install
命令,因此您需要在rm ~/.pydistutils.cfg
以后执行.
我在使用带有 -t(--target) 选项的 pip 安装 python 模块时遇到了类似的错误。
pip 日志显示下一条消息:
命令 /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
和下一个错误:
不能将用户与前缀、exec_prefix/home 或 install_(plat)base 结合使用
阅读关于python 文档的替代安装我看到下一个信息
请注意,各种备用安装方案是相互排斥的:您可以通过 --user、或 --home、或 --prefix 和 --exec-prefix、或 --install-base 和 --install-platbase,但您可以不要混合来自这些群体。
所以pip执行的命令有两个互斥的方案--user和--home(我认为这可能是pip上的一个错误)。
我使用--system选项来避免错误,消除设置命令上的 --user 标志。
pip install -t path_to_dir module_name --system
我不知道这种用法的其他含义,但我认为这比修改与正常安装混淆的配置文件要好。
PD:我使用 ubuntu 15.10 和 pip 1.5.6