Skip to main content
 首页 » 编程设计

python之在 Mac (OS X 10.11.1) 上安装 mrjob 时出错

2025年05月04日15yjmyzz

在终端中输入

pip install mrjob

给出错误信息:“NameError: name 'execfile' is not defined”和“Command 'python setup.py egg_info' failed with error code 1 in/private...”

使用

sudo pip install mrjob

也给出相同的错误信息。此外,它还提供以下消息:

Password: The directory '/Users/.../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/.../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.

如何成功安装?

请您参考如下方法:

在 March 2015 之间和 May 2015 年,mrjob setup.py 使用了 Python-2 独有的内置函数 execfile ,已从 Python 3 built-in functions 中删除.

您遇到的 NameError 强烈表明问题是由于使用 Python 3 解释器造成的。

该项目有一个 similar bug 2015年9月提出,当时修复的setup.py还没有发布。看来此错误已在 v0.5.0 中修复,2016 年 3 月 28 日发布。

要安装,请使用版本标准:

pip install --user "mrjob>=5" 

升级 pip 也可能会解决您提到的关于 sudo 的问题,但这似乎是一个不相关的问题,最好在单独的问题中解决。