简体   繁体   English

在山狮上安装Scipy

[英]Installing Scipy on Mountain Lion

I was trying to install python and its scientific libraries on a clean install of Mountain Lion, with Xcode and its command line tools. 我试图使用Xcode及其命令行工具在山狮的干净安装上安装python及其科学库。

I installed homebrew and, through it, a fresh python 2.7 as I didn't want to mess up with the one Apple provides. 我安装了自制软件,并通过它安装了一个新的python 2.7,因为我不想搞砸Apple提供的那个。 I also installed gfortran always via homebrew. 我也总是通过自制软件安装gfortran。

Then I install Numpy from its source, using the flag to build it using gfortran. 然后我从源代码安装Numpy,使用标志使用gfortran构建它。 I did this because if I pip install it then the scipy installation will fail. 我这样做是因为如果我pip安装它,那么scipy安装将失败。

With installed, I tested it through bumpy.test('full') and it says OK. 安装完成后,我通过bumpy.test('full')对它进行了测试,然后就可以了。

At this point I tried to install scipy, both using pip or from source. 此时我尝试使用pip或源代码安装scipy。 The result is the same, it installs but i get a HUGE number of failures and one error when I test it using scipy.test(). 结果是相同的,它安装但我得到了大量的失败和一个错误,当我使用scipy.test()测试它。 Any idea of how to fix this? 知道怎么解决这个问题吗?

The reported error is 报告的错误是

ERROR: test_logm_consistency (test_matfuncs.TestExpM)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/tests/test_matfuncs.py", line 124, in test_logm_consistency
    assert_array_almost_equal(expm(logm(a)), a)
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/matfuncs.py", line 453, in logm
    errest = norm(expm(F)-A,1) / norm(A,1)
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/matfuncs.py", line 49, in expm
    A_L1 = norm(A,1)
  File "/usr/local/lib/python2.7/site-packages/scipy/linalg/misc.py", line 12, in norm
    a = np.asarray_chkfinite(a)
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 590, in asarray_chkfinite
    "array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs

The failures are instead related to boas, basic, dot, asum, nrm2, arpack. 相反,失败与boas,basic,dot,asum,nrm2,arpack有关。

Any idea of how to fix this? 知道怎么解决这个问题吗?

My advice is to always set up python computing enviroments (especially with finicky packages like scipy and numpy) in a virtualenv . 我的建议是总是在virtualenv中设置python计算环境(特别是像scipy和numpy这样的挑剔包)。 virtualenv is a tool that allows you to set up and switch in and out of isolated python environments, so that installing and changing things in one environment doesn't mess with the others. virtualenv是一个工具,允许您设置和切换进出孤立的python环境,以便在一个环境中安装和更改东西不会弄乱其他环境。

EDIT: another reason to use virtualenv is that if you screw everything up, you haven't messed up your global system configuration and you can just delete the virtualenv and start over from scratch to fix it. 编辑:使用virtualenv的另一个原因是,如果你搞砸了一切,你没有弄乱你的全局系统配置,你可以删除virtualenv并从头开始修复它。 I also recommend virtualenvwrapper which is basically just some sugar that makes virtualenv more intuitive and faster to use. 我还推荐virtualenvwrapper ,它基本上只是一些糖,使virtualenv更直观,更快速地使用。

Also to address your actual question: I believe that you still have to use the development branch of scipy in order for it to compile successfully on OSX 10.8. 还要解决你的实际问题:我相信你仍然需要使用scipy的开发分支才能在OSX 10.8上成功编译。 I followed the instructions here pretty much exactly and everything worked fine. 我完全按照这里的说明进行操作,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM