安装Homebrew
Mac最好能安装Homebrew,这样你安装软件会方便得多,当然也可以手工类似Linux下进行编译安装,这个看个人喜好。
|
|
注意:这个命令因github地址调整过一次,因此和大部分文章提到的地址不太一样,可去官网查看https://brew.sh
通过brew安装 Python3.6
|
|
编译安装 Python3.6
|
|
替换配置
因Mac OS X 10.11中引入Rootless机制,作用如下:
- /System文件夹下的所有文件都不能被苹果应用以外的程序修改(例如各种安装器和升级部件)
- 当前的API例如task_for_pid不能在系统进程下被调用了。这意味着以前注入系统进程(Finder、Messages或者系统内核)的程序都不能用了。
- rootless依然允许已签名的KEXT内核拓展被载入。而且KEXT可以进行许多无限制的系统及操作。
所以我们不能直接修改/System文件夹下的所有文件, 如果是在OS X 10.11系统下,这里需要先将这个机制关掉。
关闭
- 重启电脑, 重启过程中按住command+R, 进入恢复模式
- 选择任意语言,进入选择磁盘界面
- 在顶部状态栏打开terminal,键入: csrutil disable
- 重启电脑
开启
- 重启电脑, 重启过程中按住command+R, 进入恢复模式
- 选择任意语言,进入选择磁盘界面
- 在顶部状态栏打开terminal,键入: csrutil enable
- 重启电脑
|
|
遇到的问题
pip安装包出现SSL module缺失
|
|
原因:Apple has deprecated use of the system-supplied OpenSSL libraries and with the latest releases no longer supply the header files needed to build with them. They are very old anyway. So, you need to supply a version of them. The easiest way is to get them from a third-party package manager like Homebrew or MacPorts but you certainly can download an OpenSSL source release from https://www.openssl.org and build the libraries themselves. If you do not have administrator access, you will probably need to modify the OpenSSL build using at least –prefix to install to a non-system location and then rerun Python’s ./configure with CFLAGS and LDFLAGS pointing to the installed location of your OpenSSL.
(大致意思就是说,Apple已经在高版本系统中移除了系统提供的OpenSSL库,新版本不再提供与它们一起构建所需的头文件解决方案:下载Mac版的Python包https://www.python.org/ftp/python/3.6.1/python-3.6.1-macosx10.6.pkg ,安装成功后执行如下命令
123$ export CFLAGS="-I/usr/local/opt/openssl/include"$ export LDFLAGS="-L/usr/local/opt/openssl/lib"$ pip install pandas然后卸载pkg包即可。
dtype(‘float64’) to dtype(‘int64’)
原因: Python3.x不向下兼容出现TypeError: Cannot cast ufunc subtract output from dtype(‘float64’) to dtype(‘int64’)
解决方案:将数据进行astype(“float64”)转换
如 ARMA(data, order = (p, q)) 转换为
ARMA(data.astype(“float64”), order = (p, q))
‘float’ object cannot be interpreted as an integer
- 原因:Python3.x 因为出现类似
for i in range(100 / 10)的情况 ,(100 / 10) 得到10.0,如果参与循环就会出现问题。 - 解决方案:将代码修改为:
for i in range(100 // 10) 既可避免
如果后面遇到问题继续补充!
(The End)