在Ubuntu上安装SciPy / Python

SciPy/Python install on Ubuntu

我目前正在按照教程安装SciPy Stack在Ubuntu 12.04(精确穿山甲)上安装SciPy(我不能使用apt-get install,因为我需要最新版本)。

但是,当我执行以下命令时出现错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
python setup.py build
sudo python setup.py install --prefix=/usr/local   # Installs to /usr/local

python setup.py build

michael@michael-laptop-ubuntu:~/Downloads/scipy-0.11.0rc1$ python setup.py buildRunning from scipy source directory.
blas_opt_info:
blas_mkl_info:
  libraries mkl,vml,guide not found in /usr/local/lib
  libraries mkl,vml,guide not found in /usr/lib
  libraries mkl,vml,guide not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/sse2
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/i386-linux-gnu/sse2
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

atlas_blas_info:
  libraries f77blas,cblas,atlas not found in /usr/local/lib
  libraries f77blas,cblas,atlas not found in /usr/lib/sse2
  libraries f77blas,cblas,atlas not found in /usr/lib
  libraries f77blas,cblas,atlas not found in /usr/lib/i386-linux-gnu/sse2
  libraries f77blas,cblas,atlas not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1423: 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__)
blas_info:
  libraries blas not found in /usr/local/lib
  libraries blas not found in /usr/lib
  libraries blas not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1432: 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__)
blas_src_info:
  NOT AVAILABLE

/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1435: 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__)
Traceback (most recent call last):
  File"setup.py", line 208, in <module>
    setup_package()
  File"setup.py", line 199, in setup_package
    configuration=configuration )
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/core.py", line 152, in setup
    config = configuration()
  File"setup.py", line 136, in configuration
    config.add_subpackage('scipy')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/setup.py", line 8, in configuration
    config.add_subpackage('integrate')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/integrate/setup.py", line 10, in configuration
    blas_opt = get_info('blas_opt',notfound_action=2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 320, in get_info
    return cl().get_info(notfound_action)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 471, in get_info
    raise self.notfounderror(self.notfounderror.__doc__)
numpy.distutils.system_info.BlasNotFoundError:
    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.
Error in sys.excepthook:
Traceback (most recent call last):
  File"/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File"/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report
  File"/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
    import problem_report
  File"/usr/lib/python2.7/dist-packages/problem_report.py", line 14, in <module>
    import zlib, base64, time, sys, gzip, struct, os
  File"/usr/lib/python2.7/gzip.py", line 10, in <module>
    import io
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/__init__.py", line 83, in <module>
    from matlab import loadmat, savemat, byteordercodes
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/matlab/__init__.py", line 11, in <module>
    from mio import loadmat, savemat
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/matlab/mio.py", line 15, in <module>
    from mio4 import MatFile4Reader, MatFile4Writer
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/matlab/mio4.py", line 9, in <module>
    import scipy.sparse
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/__init__.py", line 180, in <module>
    from csr import *
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/csr.py", line 12, in <module>
    from sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/sparsetools/__init__.py", line 4, in <module>
    from csr import *
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/sparsetools/csr.py", line 25, in <module>
    _csr = swig_import_helper()
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/sparsetools/csr.py", line 17, in swig_import_helper
    import _csr
ImportError: No module named _csr

Original exception was:
Traceback (most recent call last):
  File"setup.py", line 208, in <module>
    setup_package()
  File"setup.py", line 199, in setup_package
    configuration=configuration )
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/core.py", line 152, in setup
    config = configuration()
  File"setup.py", line 136, in configuration
    config.add_subpackage('scipy')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/setup.py", line 8, in configuration
    config.add_subpackage('integrate')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/integrate/setup.py", line 10, in configuration
    blas_opt = get_info('blas_opt',notfound_action=2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 320, in get_info
    return cl().get_info(notfound_action)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 471, in get_info
    raise self.notfounderror(self.notfounderror.__doc__)
numpy.distutils.system_info.BlasNotFoundError:
    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.

sudo python setup.py install --prefix = / usr / local #installs to / usr / local

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
michael@michael-laptop-ubuntu:~/Downloads/scipy-0.11.0rc1$ sudo python setup.py install --prefix=/usr/local
[sudo] password for michael:
Running from scipy source directory.
blas_opt_info:
blas_mkl_info:
  libraries mkl,vml,guide not found in /usr/local/lib
  libraries mkl,vml,guide not found in /usr/lib
  libraries mkl,vml,guide not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/sse2
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/i386-linux-gnu/sse2
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

atlas_blas_info:
  libraries f77blas,cblas,atlas not found in /usr/local/lib
  libraries f77blas,cblas,atlas not found in /usr/lib/sse2
  libraries f77blas,cblas,atlas not found in /usr/lib
  libraries f77blas,cblas,atlas not found in /usr/lib/i386-linux-gnu/sse2
  libraries f77blas,cblas,atlas not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1423: 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__)
blas_info:
  libraries blas not found in /usr/local/lib
  libraries blas not found in /usr/lib
  libraries blas not found in /usr/lib/i386-linux-gnu
  NOT AVAILABLE

/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1432: 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__)
blas_src_info:
  NOT AVAILABLE

/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1435: 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__)
Traceback (most recent call last):
  File"setup.py", line 208, in <module>
    setup_package()
  File"setup.py", line 199, in setup_package
    configuration=configuration )
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/core.py", line 152, in setup
    config = configuration()
  File"setup.py", line 136, in configuration
    config.add_subpackage('scipy')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/setup.py", line 8, in configuration
    config.add_subpackage('integrate')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/integrate/setup.py", line 10, in configuration
    blas_opt = get_info('blas_opt',notfound_action=2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 320, in get_info
    return cl().get_info(notfound_action)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 471, in get_info
    raise self.notfounderror(self.notfounderror.__doc__)
numpy.distutils.system_info.BlasNotFoundError:
    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.
Error in sys.excepthook:
Traceback (most recent call last):
  File"/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File"/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report
  File"/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
    import problem_report
  File"/usr/lib/python2.7/dist-packages/problem_report.py", line 14, in <module>
    import zlib, base64, time, sys, gzip, struct, os
  File"/usr/lib/python2.7/gzip.py", line 10, in <module>
    import io
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/__init__.py", line 83, in <module>
    from matlab import loadmat, savemat, byteordercodes
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/matlab/__init__.py", line 11, in <module>
    from mio import loadmat, savemat
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/matlab/mio.py", line 15, in <module>
    from mio4 import MatFile4Reader, MatFile4Writer
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/io/matlab/mio4.py", line 9, in <module>
    import scipy.sparse
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/__init__.py", line 180, in <module>
    from csr import *
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/csr.py", line 12, in <module>
    from sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/sparsetools/__init__.py", line 4, in <module>
    from csr import *
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/sparsetools/csr.py", line 25, in <module>
    _csr = swig_import_helper()
  File"/home/michael/Downloads/scipy-0.11.0rc1/scipy/sparse/sparsetools/csr.py", line 17, in swig_import_helper
    import _csr
ImportError: No module named _csr

Original exception was:
Traceback (most recent call last):
  File"setup.py", line 208, in <module>
    setup_package()
  File"setup.py", line 199, in setup_package
    configuration=configuration )
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/core.py", line 152, in setup
    config = configuration()
  File"setup.py", line 136, in configuration
    config.add_subpackage('scipy')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/setup.py", line 8, in configuration
    config.add_subpackage('integrate')
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
    caller_level = 2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
    caller_level = caller_level + 1)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File"scipy/integrate/setup.py", line 10, in configuration
    blas_opt = get_info('blas_opt',notfound_action=2)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 320, in get_info
    return cl().get_info(notfound_action)
  File"/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py", line 471, in get_info
    raise self.notfounderror(self.notfounderror.__doc__)
numpy.distutils.system_info.BlasNotFoundError:
    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.

此外,如何测试此模块是否正确安装?


我通常的工作流程是使用virtualenv来获得带有最新软件包的Python发行版。

在此环境中,您可以使用pip安装和更新所需的所有软件包,而无需任何sudo调用。

因此,如果您只需要SciPy(和NumPy),那将是:

1
2
3
4
5
6
7
8
$ sudo apt-get install python-virtualenv python-pip
$ sudo apt-get build-dep python-numpy python-scipy
$ # Create virtualenv in home
$ virtualenv .myenv
$ # Activate the virtualenv
$ source .myenv/bin/activate
(myenv)$ pip install -U numpy
(myenv)$ pip install -U scipy

(如果您没有root访问权限,则可以按照此处的说明安装virtualenvpip。但是,您需要NumPy和SciPy的依赖项。)

您可以在.bash_profile中包含source .myenv/bin/activate,并且您的shell将始终以该环境开头。如果使用需求文件,则可以轻松地在所有计算机上安装和维护相同的环境。


有同样的问题。以下对我有用:

1
2
3
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
sudo apt-get install gfortran


您需要按照输出建议下载并安装Atlas。之后,重试SciPy安装。

其他选项是apt-get install旧版本。这将自动安装所有依赖项;然后手动安装新的。这将导致您的计算机上有两个库,一个在/usr/share/pyshared中,另一个在/usr/local下,但是您可以通过更改模块加载路径来确保加载哪个库。

此外,如果您将省略--prefix=/usr/local,在较旧版本之上安装较新版本时,它将被覆盖,并且不需要路径修改。


您正在尝试从源代码构建SciPy。

如果您只想安装SciPy,请使用以下命令:

1
sudo apt-get install python-scipy


我遇到了与OP相同的问题(在Red Hat Linux 5.7上对我来说;是的,我知道它已经过时了)所有这些都是通过安装ATLAS标头(和"静态库",它说)来解决的:

1
 yum install atlas-devel

PyPM是安装它的好方法。版本是beta 0.10.1,它包含所有依赖项。您需要Active Python来访问PyPM,但您应该能够轻松安装。

1
pypm install scipi


对于Fedora 20:

1
2
3
4
pip install virtualenv virtualenvwrapper
mkvirtualenv scipy_project
sudo yum-buildep scipy
pip install scipy

我希望它有所帮助!