【问题标题】:pip throws exception during installation of packagepip 在安装包期间抛出异常
【发布时间】:2017-09-26 15:30:18
【问题描述】:

这里是新手错误。 我确实在我的 Mac 上安装了 Homebrew 和 pip,但在安装过程中出现了一些复杂情况。 例如,对于 pip,我的权限被拒绝。我去谷歌找到了“sudo - H”解决方案。但是有一些关于禁用轮子和日志的消息,我不小心退出了终端。

是否有任何命令让 pip 和 Homebrew 获取状态报告,比如一切正常或删除并重新安装是最好的方法?

编辑: 尝试在 pip 和 Homebrew 中安装一个包,如建议的那样,w/o sudo -h 得到了这个:

Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
 status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
 prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
 **kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
 self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
 isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
 clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 323, in clobber
 shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
 with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/bellite.pyc'

不过好像和Python 2.7有关,我一点都不感兴趣。

当我使用 sudo -h 时,我得到了:

The directory '/Users/SimonOsipov/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/SimonOsipov/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Homebrew 安装包有 0 个问题

【问题讨论】:

  • 你可以尝试通过 homebrew/pip 安装一个包,看看它是否正常工作......
  • 你可以试试 brew reinstall 命令。
  • 尝试安装任何软件包。如果pip 抛出有关文件权限的错误,则它无法正常工作。
  • 试过了,检查编辑。
  • 你应该让你的问题标题比“如何检查一切是否正常”更能提供信息。

标签: python pip homebrew


【解决方案1】:

您会收到 Permission denied 错误,因为默认情况下 pip 会尝试在系统范围内安装其软件包。这里没有什么不正常的。

你可以使用--user在你自己的用户下安装包:

pip install --user ...

是否有任何命令让 pip 和 Homebrew 获取状态报告,例如一切正常或删除并重新安装是最好的方法?

Homebrew 有一个brew doctor 命令,可以帮助您诊断系统上的潜在问题。如果它不能正常工作,这是一个很好的起点。 pip 没有,但它支持-v 选项,以获得更详细的输出,最多可以使用三倍;例如pip install -vvv ....

【讨论】:

    【解决方案2】:

    尝试 brew install (您在此处选择的软件包)。如果这有效,那很好。

    尝试 pip install(在这里再次选择您选择的软件包)。如果这行得通,你可能很高兴。

    如果两者都不起作用,请尝试卸载 brew 和 pip 然后重新开始。如果两者都有效,您可能就可以开始了。

    您还可以熟悉 brew cleanup、brew upgrade、brew update 和 brew doctor 等命令。

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-07
      • 1970-01-01
      • 2017-07-08
      • 2016-06-11
      • 2011-01-11
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多