pip在安装包时抛出异常

时间:2017-09-26 15:30:19

标签: python pip homebrew

新秀在这里犯了错误。 我确实在我的Mac上安装了Homebrew和pip,但在安装过程中出现了一些问题。 例如,对于pip,我获得了权限被拒绝。我去谷歌找到" sudo - H"解。但是有一些关于禁用车轮和日志的消息,我不小心退出终端。

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

编辑: 尝试按照建议安装pip和Homebrew的软件包,没有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个问题

2 个答案:

答案 0 :(得分:1)

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

您可以使用--user

在自己的用户下安装软件包
pip install --user ...
  

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

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

答案 1 :(得分:0)

尝试brew install(您在此处选择包)。如果有效,那就好了。

尝试pip install(再次选择你的包)。如果可行的话,你可能会很高兴。

如果两者都不起作用,只需尝试卸载brew和pip,然后重新开始。如果两者都有效,那么你可能会很高兴。

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

希望有所帮助。