安装scipy报错的解决方案
在系统中安装scipy时,用pip3 install scipy命令进行安装出现下面错误:Preparing wheel metadata ... errorERROR: Command errored out with exit status 1:command: /home/python3.7.5/bin/python3.7 /home/python3.7.5/lib/python3.7/si
·
在系统中安装scipy时,用pip3 install scipy命令进行安装出现下面错误:
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /home/python3.7.5/bin/python3.7 /home/python3.7.5/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpvbhpwnet
cwd: /tmp/pip-install-j4hlkwg4/scipy
Complete output (156 lines):
Running scipy/linalg/_generate_pyx.py
Running scipy/stats/_generate_pyx.py
Running scipy/special/_generate_pyx.py
Processing scipy/linalg/cython_blas.pyx
Processing scipy/linalg/_matfuncs_sqrtm_triu.pyx
Processing scipy/linalg/_decomp_update.pyx.in
Processing scipy/linalg/cython_lapack.pyx
Processing scipy/linalg/_solve_toeplitz.pyx
Processing scipy/stats/_stats.pyx
Processing scipy/stats/biasedurn.pyx
Processing scipy/stats/_qmc_cy.pyx
Processing scipy/stats/_sobol.pyx
Processing scipy/stats/_boost/src/beta_ufunc.pyx
Processing scipy/stats/_boost/src/binom_ufunc.pyx
Processing scipy/stats/_boost/src/nbinom_ufunc.pyx
Processing scipy/sparse/_csparsetools.pyx.in
Processing scipy/sparse/csgraph/_tools.pyx
Processing scipy/sparse/csgraph/_traversal.pyx
Processing scipy/sparse/csgraph/_flow.pyx
Processing scipy/sparse/csgraph/_min_spanning_tree.pyx
Processing scipy/sparse/csgraph/_matching.pyx
Processing scipy/sparse/csgraph/_reordering.pyx
Processing scipy/sparse/csgraph/_shortest_path.pyx
Processing scipy/fftpack/convolve.pyx
Processing scipy/special/_comb.pyx
Processing scipy/special/_ufuncs.pyx
Processing scipy/special/cython_special.pyx
Processing scipy/special/_ufuncs_cxx.pyx
Processing scipy/special/_ellip_harm_2.pyx
Processing scipy/special/_test_round.pyx
Processing scipy/_lib/_test_deprecation_def.pyx
Processing scipy/_lib/_test_deprecation_call.pyx
Processing scipy/_lib/_ccallback_c.pyx
Processing scipy/_lib/messagestream.pyx
Processing scipy/ndimage/src/_ni_label.pyx
Processing scipy/ndimage/src/_cytest.pyx
Processing scipy/io/matlab/streams.pyx
Processing scipy/io/matlab/mio5_utils.pyx
Processing scipy/io/matlab/mio_utils.pyx
warning: _cython_special_custom.pxi:9:8: Unreachable code
warning: _cython_special_custom.pxi:13:4: Unreachable code
warning: _cython_special_custom.pxi:21:8: Unreachable code
warning: _cython_special_custom.pxi:25:4: Unreachable code
warning: _cython_special_custom.pxi:33:8: Unreachable code
warning: _cython_special_custom.pxi:37:4: Unreachable code
warning: _cython_special_custom.pxi:45:8: Unreachable code
warning: _cython_special_custom.pxi:49:4: Unreachable code
Processing scipy/interpolate/_ppoly.pyx
Processing scipy/interpolate/interpnd.pyx
Processing scipy/interpolate/_bspl.pyx
Processing scipy/cluster/_optimal_leaf_ordering.pyx
Processing scipy/cluster/_hierarchy.pyx
Processing scipy/cluster/_vq.pyx
Processing scipy/signal/_peak_finding_utils.pyx
Processing scipy/signal/_max_len_seq_inner.pyx
Processing scipy/signal/_spectral.pyx
Processing scipy/signal/_sosfilt.pyx
Processing scipy/signal/_upfirdn_apply.pyx
Processing scipy/spatial/_voronoi.pyx
Processing scipy/spatial/ckdtree.pyx
Processing scipy/spatial/_hausdorff.pyx
Processing scipy/spatial/qhull.pyx
Processing scipy/spatial/transform/rotation.pyx
Processing scipy/optimize/_group_columns.pyx
Processing scipy/optimize/_bglu_dense.pyx
Processing scipy/optimize/_lsq/givens_elimination.pyx
Processing scipy/optimize/_highs/cython/src/_highs_wrapper.pyx
Processing scipy/optimize/_highs/cython/src/_highs_constants.pyx
Processing scipy/optimize/_trlib/_trlib.pyx
Processing scipy/optimize/cython_optimize/_zeros.pyx.in
Cythonizing sources
lapack_opt_info:
lapack_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/home/python3.7.5/lib', '/usr/local/lib', '/usr/lib', '/usr/lib/aarch64-linux-gnu']
NOT AVAILABLE
openblas_lapack_info:
C compiler: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC
creating /tmp/tmpka583a2d/tmp
creating /tmp/tmpka583a2d/tmp/tmpka583a2d
compile options: '-c'
gcc: /tmp/tmpka583a2d/source.c
gcc -pthread /tmp/tmpka583a2d/tmp/tmpka583a2d/source.o -L/usr/lib/aarch64-linux-gnu -lopenblas -o /tmp/tmpka583a2d/a.out
FOUND:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/lib/aarch64-linux-gnu']
language = c
define_macros = [('HAVE_CBLAS', None)]
FOUND:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/lib/aarch64-linux-gnu']
language = c
define_macros = [('HAVE_CBLAS', None)]
setup.py:492: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /tmp/pip-install-j4hlkwg4/scipy/pip-wheel-metadata'), proceeding with generating Cython sources and expanding templates
' '.join(sys.argv[1:])))
Running from SciPy source directory.
Traceback (most recent call last):
File "/home/python3.7.5/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/home/python3.7.5/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/python3.7.5/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 69, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 166, in prepare_metadata_for_build_wheel
self.run_setup()
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 259, in run_setup
self).run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 629, in <module>
setup_package()
File "setup.py", line 625, in setup_package
setup(**metadata)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "setup.py", line 536, in configuration
config.add_subpackage('scipy')
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 1020, in add_subpackage
caller_level = 2)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 989, in get_subpackage
caller_level = caller_level + 1)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 926, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/setup.py", line 12, in configuration
config.add_subpackage('interpolate')
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 1020, in add_subpackage
caller_level = 2)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 989, in get_subpackage
caller_level = caller_level + 1)
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 926, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/interpolate/setup.py", line 58, in configuration
from pythran.dist import PythranExtension
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/pythran/__init__.py", line 40, in <module>
from pythran.toolchain import (generate_cxx, compile_cxxfile, compile_cxxcode,
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/pythran/toolchain.py", line 6, in <module>
from pythran.backend import Cxx, Python
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/pythran/backend.py", line 7, in <module>
from pythran.analyses import LocalNodeDeclarations, GlobalDeclarations, Scope
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/pythran/analyses/__init__.py", line 14, in <module>
from .argument_effects import ArgumentEffects
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/pythran/analyses/argument_effects.py", line 11, in <module>
import networkx as nx
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/networkx/__init__.py", line 57, in <module>
from networkx import utils
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/networkx/utils/__init__.py", line 2, in <module>
from networkx.utils.decorators import *
File "/tmp/pip-build-env-vib5jyd3/overlay/lib/python3.7/site-packages/networkx/utils/decorators.py", line 12, in <module>
import re, gzip, bz2
File "/home/python3.7.5/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
----------------------------------------
ERROR: Command errored out with exit status 1: /home/python3.7.5/bin/python3.7 /home/python3.7.5/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpvbhpwnet Check the logs for full command output.
仔细观察会发现是由于:ModuleNotFoundError: No module named '_bz2'引起的错误。在此处我安装python3.7.5时,是使用源码编译的。在编译之前需要安装依赖包,这是由于在安装依赖包的时候没有安装bz2导致的。
解决方案:在编译之前,需要使用下面命令安装依赖包:
apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev libsqlite3-dev openssl libssl-dev libffi-dev unzip pciutils net-tools libblas-dev gfortran libblas3 libopenblas-dev libbz2-dev
因为一些教程中没有libbz2-dev这一项,导致了后续安装scipy安装失败。
在此记录一下,方便自己不再犯同样的错误。
更多推荐
已为社区贡献2条内容
所有评论(0)