我正在嘗試安裝 numpy,但由於某種原因安裝而一直失敗。
其實我需要的是python的諾學習,但 numpy (和 scipy)是依賴項。
所以我跑了:
sudo pip install numpy
但安裝日誌失敗:
Downloading/unpacking numpy
Running setup.py (path:/tmp/pip_build_root/numpy/setup.py) egg_info for package numpy
Running from numpy source directory.
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
Installing collected packages: numpy
Running setup.py install for numpy
/bin/sh: 1: svnversion: not found
non-existing path in 'numpy/distutils': 'site.cfg'
non-existing path in 'numpy/f2py': 'docs'
non-existing path in 'numpy/f2py': 'f2py.1'
F2PY Version 2
blas_opt_info:
blas_mkl_info:
libraries mkl,vml,guide not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
NOT AVAILABLE
openblas_info:
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
/bin/sh: 1: svnversion: not found
non-existing path in 'numpy/lib': 'benchmarks'
lapack_opt_info:
openblas_lapack_info:
C compiler: cc
compile options: '-c'
cc: /tmp/tmpazdxtcf1/source.c
cc /tmp/tmpazdxtcf1/tmp/tmpazdxtcf1/source.o -lopenblas -o /tmp/tmpazdxtcf1/a.out
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
build_src
building py_modules sources
building library "npymath" sources
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using config
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
x86_64-linux-gnu-gcc -pthread _configtest.o -o _configtest
success!
removing: _configtest.c _configtest.o _configtest
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’
int exp (void);
^
x86_64-linux-gnu-gcc -pthread _configtest.o -o _configtest
_configtest.o: In function `main':
/tmp/pip_build_root/numpy/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
_configtest.o: In function `main':
/tmp/pip_build_root/numpy/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
failure.
removing: _configtest.c _configtest.o
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’
int exp (void);
^
x86_64-linux-gnu-gcc -pthread _configtest.o -lm -o _configtest
success!
removing: _configtest.c _configtest.o _configtest
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npymath/npy_math.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npymath/ieee754.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npymath/npy_math_complex.c
building library "npysort" sources
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/quicksort.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/mergesort.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/heapsort.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/private/npy_partition.h
adding 'build/src.linux-x86_64-3.4/numpy/core/src/private' to include_dirs.
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/selection.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/private/npy_binsearch.h
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/binsearch.c
None - nothing done with h_files = ['build/src.linux-x86_64-3.4/numpy/core/src/private/npy_partition.h', 'build/src.linux-x86_64-3.4/numpy/core/src/private/npy_binsearch.h']
building extension "numpy.core._dummy" sources
Generating build/src.linux-x86_64-3.4/numpy/core/include/numpy/config.h
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
_configtest.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
_configtest.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
failure.
removing: _configtest.c _configtest.o
Running from numpy source directory.
/usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip_build_root/numpy/setup.py", line 251, in <module>
setup_package()
File "/tmp/pip_build_root/numpy/setup.py", line 243, in setup_package
setup(**metadata)
File "/tmp/pip_build_root/numpy/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/install.py", line 62, in run
r = self.setuptools_run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "/usr/lib/python3.4/distutils/command/install.py", line 583, in run
self.run_command('build')
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build.py", line 39, in run
old_build.run(self)
File "/usr/lib/python3.4/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 153, in run
self.build_sources()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 170, in build_sources
self.build_extension_sources(ext)
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 329, in build_extension_sources
sources = self.generate_sources(sources, ext)
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 432, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 42, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 293, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lsbot4u_-record/install-record.txt --single-version-externally-managed --compile:
/bin/sh: 1: svnversion: not found
non-existing path in 'numpy/distutils': 'site.cfg'
non-existing path in 'numpy/f2py': 'docs'
non-existing path in 'numpy/f2py': 'f2py.1'
F2PY Version 2
blas_opt_info:
blas_mkl_info:
libraries mkl,vml,guide not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
NOT AVAILABLE
openblas_info:
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
/bin/sh: 1: svnversion: not found
non-existing path in 'numpy/lib': 'benchmarks'
lapack_opt_info:
openblas_lapack_info:
C compiler: cc
creating /tmp/tmpazdxtcf1/tmp
creating /tmp/tmpazdxtcf1/tmp/tmpazdxtcf1
compile options: '-c'
cc: /tmp/tmpazdxtcf1/source.c
cc /tmp/tmpazdxtcf1/tmp/tmpazdxtcf1/source.o -lopenblas -o /tmp/tmpazdxtcf1/a.out
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
FOUND:
libraries = ['openblas']
language = f77
library_dirs = ['/usr/lib']
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
creating build
creating build/src.linux-x86_64-3.4
creating build/src.linux-x86_64-3.4/numpy
creating build/src.linux-x86_64-3.4/numpy/distutils
building library "npymath" sources
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using config
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
x86_64-linux-gnu-gcc -pthread _configtest.o -o _configtest
success!
removing: _configtest.c _configtest.o _configtest
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’
int exp (void);
^
x86_64-linux-gnu-gcc -pthread _configtest.o -o _configtest
_configtest.o: In function `main':
/tmp/pip_build_root/numpy/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
_configtest.o: In function `main':
/tmp/pip_build_root/numpy/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
failure.
removing: _configtest.c _configtest.o
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’
int exp (void);
^
x86_64-linux-gnu-gcc -pthread _configtest.o -lm -o _configtest
success!
removing: _configtest.c _configtest.o _configtest
creating build/src.linux-x86_64-3.4/numpy/core
creating build/src.linux-x86_64-3.4/numpy/core/src
creating build/src.linux-x86_64-3.4/numpy/core/src/npymath
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npymath/npy_math.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npymath/ieee754.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npymath/npy_math_complex.c
building library "npysort" sources
creating build/src.linux-x86_64-3.4/numpy/core/src/npysort
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/quicksort.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/mergesort.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/heapsort.c
creating build/src.linux-x86_64-3.4/numpy/core/src/private
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/private/npy_partition.h
adding 'build/src.linux-x86_64-3.4/numpy/core/src/private' to include_dirs.
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/selection.c
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/private/npy_binsearch.h
conv_template:> build/src.linux-x86_64-3.4/numpy/core/src/npysort/binsearch.c
None - nothing done with h_files = ['build/src.linux-x86_64-3.4/numpy/core/src/private/npy_partition.h', 'build/src.linux-x86_64-3.4/numpy/core/src/private/npy_binsearch.h']
building extension "numpy.core._dummy" sources
Generating build/src.linux-x86_64-3.4/numpy/core/include/numpy/config.h
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python3.4m -c'
x86_64-linux-gnu-gcc: _configtest.c
_configtest.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
_configtest.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
failure.
removing: _configtest.c _configtest.o
Running from numpy source directory.
/usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip_build_root/numpy/setup.py", line 251, in <module>
setup_package()
File "/tmp/pip_build_root/numpy/setup.py", line 243, in setup_package
setup(**metadata)
File "/tmp/pip_build_root/numpy/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/install.py", line 62, in run
r = self.setuptools_run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "/usr/lib/python3.4/distutils/command/install.py", line 583, in run
self.run_command('build')
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build.py", line 39, in run
old_build.run(self)
File "/usr/lib/python3.4/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 153, in run
self.build_sources()
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 170, in build_sources
self.build_extension_sources(ext)
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 329, in build_extension_sources
sources = self.generate_sources(sources, ext)
File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 432, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 42, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 293, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
----------------------------------------
Cleaning up...
Command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lsbot4u_-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/numpy
Storing debug log for failure in /home/mikel/.pip/pip.log
它說有Perhaps you need to install python-dev|python-devel
,但我沒有。當我嘗試安裝 python-dev 時,它說:
python-dev is already the newest version.
我的猜測是問題的根源是警告:
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’
int exp (void);
但我不知道如何解決這個問題。
答案1
只能用pip安裝舊版。您可能想要使用 git 安裝最新版本。
簡短的版本是:
sudo apt-get install python3.4-dev
git clone [email protected]:dnouri/nolearn.git
cd nolearn
pip install -r requirements.txt
python setup.py develop
這應該安裝包括所有要求。
您還需要 python 3.4 開發包。
資料來源: