Mac下安装软件包遇到的错误总结

最近在装一些软件包的时候,总遇到一些很难解决的错误,总结下:

scipy, seaborn

Python的包我都是采用pip来安装的

SciPy (pronounced “Sigh Pie”) is a Python-based ecosystem of open-source software for mathematics, science, and engineering. In particular, these are some of the core packages:

  • NumPy
  • SciPy
  • Matplotlib
  • IPython
  • Sympy
  • pandas

Seaborn的话,

Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics.

但是,我用pip install seaborn后,import时,出现ERROR

1
2
from . import futil
ImportError: cannot import name futil

在这之前还有个错误,这个跟个人习惯有关,我在本地创建的一个new.py的文件,正好seaborn导入时会用到new.py,由Python包导入顺序此时本地的new要优先于seaborn的new,这个”案子”提示我们自我创建文件时

  1. 目录要准确
  2. 名字不要太容易起冲突

不过这类错误一眼也能看出来.
回到刚那个错误,搜索很久,发现安装的SciPy应该是一个Broken的版本(到那个目录查看的话,会发现futil.so这个文件),更新下就好了.然而,这货根本卸载不掉

1
OSError: [Errno 1] Operation not permitted: '/tmp/pip-JPaA5b-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info'

参考解决mac osx下pip安装ipython权限的问题,终于解决了.

由于El Capitan引入了SIP机制(System Integrity Protection),默认下系统启用SIP系统完整性保护机制,无论是对于硬盘还是运行时的进程限制对系统目录的写操作。
现在的解决办法是取消SIP机制,具体做法是:
重启电脑,按住Command+R(直到出现苹果标志)进入Recovery Mode(恢复模式)
左上角菜单里找到实用工具 -> 终端
输入csrutil disable回车
重启Mac即可
如果想重新启动SIP机制重复上述步骤改用csrutil enable即可.

这下好了,然而运行下面这段代码时发现,

1
2
3
sns.set_style("whitegrid")
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
sns.boxplot(data=data);

这根本什么都没有,什么都没有,其实这个问题很早就有了……

知乎
stackoverflow

都这么长时间了,真是的,尝试了下面的所有方法,只有plt.show()这个方法能使.但是,这个”小火箭”,便退不出去了python sns
不过sns.plt倒是有很多功能,应该能够实现我们想要的.

VTK

全称是The Visulition ToolKit, 有wiki.

安装完遇到的第一个问题便是几个examples的cxx版本,几乎什么都没有
NoneVtk
似乎是VTK版本更新后,出现了这些问题,我不知道了.不过还是有其他例子可以显示的.

有些例子中包含vtkRenderWindowInteractor`即VTK交互渲染窗口是可以正常显示的,但是其他就不行了.

后来发现解决方法:

举例来说,如这个例子是VTK官方的Toturial中的step1,在cxx源代码中加入

1
2
3
4
5
6
7
8
9
10
11
#include <unistd.h>
// <...step1 code...>
for (i = 0; i < 360; ++i) //每次渲染窗口时通过usleep函数,可以让窗口保留显示一段时间
{
usleep(microseconds);

// render the image
renWin->Render();
// rotate the active camera by one degree
ren1->GetActiveCamera()->Azimuth( 1 );
}

其他

  • 安装MITK时,用Cmake编译好久,错误好多,无法解决
  • 安装Qt5,遇到错误
1
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild

后来发现是个某个版本的bug,换了其他方式安装合适的版本后ok了