Python scipy 需要 BLAS
我在我的Python程序中需要用到scipy
这个库,现在我想用setuptools
把它打包。
我在setup.py文件里写了install_requires=['scipy','matplotlib']
,意思是我需要这两个库。
然后我运行了python setup.py install
。
Processing dependencies for Bland==1.0.a.dev1
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Best match: scipy 0.13.3
Downloading https://pypi.python.org/packages/source/s/scipy/scipy-0.13.3.zip#md5=20ff3a867cc5925ef1d654aed2ff7e88
Processing scipy-0.13.3.zip
这个过程一直进行,直到出现3到4个警告和一个错误,内容如下:
ages/numpy/distutils/system_info.py:1522: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
/home/storm/Documents/bland/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:1531: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
warnings.warn(BlasNotFoundError.__doc__)
/home/storm/Documents/bland/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:1534: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
warnings.warn(BlasSrcNotFoundError.__doc__)
error:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable
我找到了一些信息,提到过这个问题,链接在这里:这个问题。这个信息是关于如何在没有setup.py
的情况下安装scipy
,它提到需要下载,然后编译Fortran文件,最后把它们链接成一个库,这个库在安装scipy
时必须在你的搜索路径里。但是我该如何在setup.py
中做到这一点,或者有没有其他的解决办法呢?
顺便说一下:我是在virtualenv
环境中运行这个的。
1 个回答
3
根据我的理解,你不能通过 setup.py
来安装系统库。这个方法只是用来处理 Python 包和它们的 C 扩展(这些扩展可能会定义它们自己对 C 共享库的依赖,但这并不是解决方案)。
你可以尝试一些其他的解决办法,但这些都不在 setup.py
文件里:
- 创建一个安装程序(比如 RPM、DEB 或 Windows 包),在里面定义你对 Atlas 包的依赖。然后系统的包管理工具(如 yum、apt-get,Windows 上没有类似的)会负责找到这个库并为你的包安装它。
- 使用 buildout 作为构建工具
- 把 Atlas 定义为一个
part
- 使用
cmmi
配方来下载、配置、编译和安装 Atlas 的压缩包 - 在你的
setup.py
文件中,在定义你的包的setup
之前,把os.environ
的 ATLAS 变量设置为你 buildout 的parts
目录。
- 把 Atlas 定义为一个
- 简单地把 Atlas 列为你包的依赖,让用户自己去安装它。把
scipy
的依赖放在你的setup.py
里;这是正确的地方,因为它是一个 Python 包。