setuptools on OSX

起因是想要装 tox,然而 pip install tox 并不能顺利跑通,报错如下:

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2w/d1r9vfrs7rjbdjdcfyzmq_2rbjm717/T/pip-build-6nwmYd/pluggy/

因为之前在官网上看到 (https://tox.readthedocs.io/en/latest/install.html)说requirement是setuptools,此外大约是上个月的时候吧,想要跑别人写的BKT的python包 (https://github.com/CAHLR/pyBKT) 结果总是报错,当时折腾了两三天,最后放弃了python转投c温暖的怀抱,为了安装XCode而升级系统真的是折腾了好久呢(后来怎么解决的来着……好像是Sierra),好吧言归正传,事后我个人坚信是因为setuptools没搞定所以python那边有很多东西没跑通,这次怎么看都觉得又是setuptools在作怪的可能性比较大。


反正试一试没损失嘛我就谷歌了一下:https://*.com/questions/26032836/how-to-install-setuptools-in-mac

看起来可以啊……

可是……我把人家 (https://pypi.python.org/pypi/setuptools) 整个项目都弄下来了,哪有什么  ez_setup.py

最好是有哦……

然后看到评论里是这么写的:

I'm not sure if this was on the page at the time of this answer, but the section Unix including Mac OS X (curl)provides a command curl https://bootstrap.pypa.io/ez_setup.py -o - | python, which does exactly as described in answer, just with a single action and without having to download/remove the file explicitly. AFAIK curl is pre-installed on every Mac OS X system. – Marko Grešak Apr 18 '15 at 16:55 


看来老外说话也是很委婉很有艺术的……明明是被指错了路嘛……不过既然解决方案是 

curl https://bootstrap.pypa.io/ez_setup.py -o - | python

那试一下……

setuptools on OSX

哎哟这回看起来十分靠谱了……


不过最初的目的是什么来着……对了,tox不解决的话不能说是完成了。

试试pip install tox

结果是:


Successfully built pluggy

Installing collected packages: pluggy, tox

Successfully installed pluggy-0.5.2 tox-2.9.1



十分完美,可以睡个好觉了终于。


这次的经历告诉我是福不是祸,是祸躲不过,别以为上次幸免于难,这次也能照葫芦画瓢,这么严肃的环境问题还是要尽快解决的啊。


又及,*上的followup discussion显示有的人不能直接跑那行命令安装setuptools。

个人十分不负责任的猜测:大概是因为没有装XCode所以没有很多C语言的标准库吧?


最后,我的系统是 Version 10.12

python因为个人习惯使然,用的是2.7