scipy在cygwin的安装

来源:互联网 发布:分贝计软件 编辑:程序博客网 时间:2024/06/06 00:22

折腾一天,总结一下:

下载lapack-3.7.1,拷贝install目录下的make.inc.gfortran.到上一级目录,改名make.inc

OPTS    = -O2 -frecursive -m64 -fPIC
DRVOPTS = $(OPTS)
NOOPT   = -O0 -frecursive -m64 -fPIC

加上m64,fPIC对于amd64没用,加上无妨

make

然后到CBLAS目录下make,生成libcblas.a

在scipy源代码目录site.cfg文件中加入

[cblas]
library_dirs = /home/wuzhiqiao/lapack-3.7.1/lapack-3.7.1
blas_libs = cblas
extra_compile_args =-m64




[blas]
library_dirs = /home/wuzhiqiao/lapack-3.7.1/lapack-3.7.1
blas_libs = blas
extra_compile_args =-m64
[lapack]
library_dirs = /home/wuzhiqiao/lapack-3.7.1/lapack-3.7.1
lapack_libs = lapack
extra_compile_args =-m64


再修改F:\cygwin64\lib\python2.7\site-packages\numpy\distutils\system_info.py文件

加入extra_preargs="-m64"


    def has_cblas(self, info):
        # primitive cblas check by looking for the header and trying to link
        # cblas or blas
        res = False
        c = distutils.ccompiler.new_compiler()
        c.customize('')
        tmpdir = tempfile.mkdtemp()
        s = """#include <cblas.h>
        int main(int argc, const char *argv[])
        {
            double a[4] = {1,2,3,4};
            double b[4] = {5,6,7,8};
            return cblas_ddot(4, a, 1, b, 1) > 10;
        }"""
        src = os.path.join(tmpdir, 'source.c')
        try:
            with open(src, 'wt') as f:
                f.write(s)


            try:
                # check we can compile (find headers)
                obj = c.compile([src], output_dir=tmpdir,
                                include_dirs=self.get_include_dirs(), extra_preargs="-m64")


最后在scipy根目录下python setup.py install,这样可以不用编译MKL